BigW Consortium Gitlab

Commit c5083357 by Filipa Lacerda

Fix code examples and add code highligth

parent 6b1b616e
...@@ -291,7 +291,7 @@ When exactly one object is needed for a given task, prefer to define it as a ...@@ -291,7 +291,7 @@ When exactly one object is needed for a given task, prefer to define it as a
`class` rather than as an object literal. Prefer also to explicitly restrict `class` rather than as an object literal. Prefer also to explicitly restrict
instantiation, unless flexibility is important (e.g. for testing). instantiation, unless flexibility is important (e.g. for testing).
``` ```javascript
// bad // bad
gl.MyThing = { gl.MyThing = {
...@@ -340,21 +340,20 @@ When writing a class that needs to manipulate the DOM guarantee a container opti ...@@ -340,21 +340,20 @@ When writing a class that needs to manipulate the DOM guarantee a container opti
This is useful when we need that class to be instantiated more than once in the same page. This is useful when we need that class to be instantiated more than once in the same page.
Bad: Bad:
``` ```javascript
class Foo { class Foo {
constructor() { constructor() {
document.querySelector('.bar'); document.querySelector('.bar');
} }
} }
new Foo(); new Foo();
``` ```
Good: Good:
``` ```javascript
class Foo { class Foo {
constructor(opts) { constructor(opts) {
document.querySelector(opts.container); opts.container.querySelector('.bar');
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment