summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-03-10 23:15:18 +0000
committerFilipa Lacerda <filipa@gitlab.com>2017-03-10 23:15:18 +0000
commitc50833571946cbabcebb3b0da9bba5b625981ab5 (patch)
tree984318ef77ed2ae74443023b3dfae7b2a53a631f
parent6b1b616ea9e30055f8fdab7c7ea012ac2d5c7269 (diff)
downloadgitlab-ce-c50833571946cbabcebb3b0da9bba5b625981ab5.tar.gz
Fix code examples and add code highligth
-rw-r--r--doc/development/frontend.md9
1 files changed, 4 insertions, 5 deletions
diff --git a/doc/development/frontend.md b/doc/development/frontend.md
index d540dce5729..c5ee44988ac 100644
--- a/doc/development/frontend.md
+++ b/doc/development/frontend.md
@@ -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
instantiation, unless flexibility is important (e.g. for testing).
-```
+```javascript
// bad
gl.MyThing = {
@@ -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.
Bad:
-```
+```javascript
class Foo {
constructor() {
document.querySelector('.bar');
}
}
-
new Foo();
```
Good:
-```
+```javascript
class Foo {
constructor(opts) {
- document.querySelector(opts.container);
+ opts.container.querySelector('.bar');
}
}