 Chromium Code Reviews
 Chromium Code Reviews Issue 2940233002:
  WebUI: Allow using ES6 classes in the styleguide.  (Closed)
    
  
    Issue 2940233002:
  WebUI: Allow using ES6 classes in the styleguide.  (Closed) 
  | OLD | NEW | 
|---|---|
| 1 <!-- Feature template markdown: | 1 <!-- Feature template markdown: | 
| 2 ## Header | 2 ## Header | 
| 3 | 3 | 
| 4 **Usage Example:** | 4 **Usage Example:** | 
| 5 | 5 | 
| 6 ```js | 6 ```js | 
| 7 | 7 | 
| 8 ``` | 8 ``` | 
| 9 | 9 | 
| 10 **Documentation:** [link]() | 10 **Documentation:** [link]() | 
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 ``` | 176 ``` | 
| 177 | 177 | 
| 178 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0/#sec-pr omise-objects) | 178 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0/#sec-pr omise-objects) | 
| 179 [link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_ Objects/Promise) | 179 [link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_ Objects/Promise) | 
| 180 | 180 | 
| 181 **Discussion Notes:** Feature already extensively used prior to creation of | 181 **Discussion Notes:** Feature already extensively used prior to creation of | 
| 182 this document. | 182 this document. | 
| 183 | 183 | 
| 184 --- | 184 --- | 
| 185 | 185 | 
| 186 ## Classes | |
| 187 | |
| 188 OOP-style and boilerplate-free class syntax, including inheritance, `super()`, | |
| 189 static members, and getters and setters. | |
| 190 | |
| 191 **Usage Example:** | |
| 192 | |
| 193 ```js | |
| 194 class Shape { | |
| 195 constructor(x, y) { | |
| 196 this.x = x; | |
| 197 this.y = y; | |
| 198 } | |
| 199 } | |
| 200 // Note: let Shape = class {...}; is also valid. | |
| 201 | |
| 202 class Rectangle extends Shape { | |
| 203 constructor(x, y, width, height) { | |
| 204 super(id, x, y); | |
| 205 this.width = width; | |
| 206 this.height = height; | |
| 207 } | |
| 208 | |
| 209 static goldenRectangle() { | |
| 210 var PHI = (1 + Math.sqrt(5)) / 2; | |
| 211 return new Rectangle(0, 0, PHI, 1); | |
| 212 } | |
| 213 } | |
| 214 ``` | |
| 215 | |
| 216 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0/#sec-cl ass-definitions) | |
| 217 | |
| 218 **Discussion Notes / Link to Thread:** | |
| 219 https://groups.google.com/a/chromium.org/d/msg/chromium-dev/S1h-0m2ohOw/jyaiMGDl CwAJ | |
| 220 | |
| 221 **Note**: => does not work in iOS9. Don't use it in code that runs on Chrome fo r | |
| 
PhistucK
2017/06/16 14:53:09
Remove "=>".
(Or replace with "classes")
 
dpapad
2017/06/16 18:09:24
Done.
 | |
| 222 iOS, unless you can verify it works. | |
| 223 | |
| 224 --- | |
| 225 | |
| 186 # Banned Features | 226 # Banned Features | 
| 187 | 227 | 
| 188 The following features are banned for Chromium development. | 228 The following features are banned for Chromium development. | 
| 189 | 229 | 
| 190 # Features To Be Discussed | 230 # Features To Be Discussed | 
| 191 | 231 | 
| 192 The following features are currently disallowed. See the top of this page on | 232 The following features are currently disallowed. See the top of this page on | 
| 193 how to propose moving a feature from this list into the allowed or banned | 233 how to propose moving a feature from this list into the allowed or banned | 
| 194 sections. | 234 sections. | 
| 195 | 235 | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 ``` | 297 ``` | 
| 258 | 298 | 
| 259 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0/#sec-le t-and-const-declarations) | 299 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0/#sec-le t-and-const-declarations) | 
| 260 | 300 | 
| 261 **See also:** [Object.freeze()](https://developer.mozilla.org/en-US/docs/Web/Jav aScript/Reference/Global_Objects/Object/freeze) | 301 **See also:** [Object.freeze()](https://developer.mozilla.org/en-US/docs/Web/Jav aScript/Reference/Global_Objects/Object/freeze) | 
| 262 | 302 | 
| 263 **Discussion Notes / Link to Thread:** | 303 **Discussion Notes / Link to Thread:** | 
| 264 | 304 | 
| 265 --- | 305 --- | 
| 266 | 306 | 
| 267 ## Classes | |
| 268 | |
| 269 OOP-style and boilerplate-free class syntax, including inheritance, `super()`, | |
| 270 static members, and getters and setters. | |
| 271 | |
| 272 **Usage Example:** | |
| 273 | |
| 274 ```js | |
| 275 class Shape { | |
| 276 constructor(x, y) { | |
| 277 this.x = x; | |
| 278 this.y = y; | |
| 279 } | |
| 280 } | |
| 281 // Note: let Shape = class {...}; is also valid. | |
| 282 | |
| 283 class Rectangle extends Shape { | |
| 284 constructor(x, y, width, height) { | |
| 285 super(id, x, y); | |
| 286 this.width = width; | |
| 287 this.height = height; | |
| 288 } | |
| 289 | |
| 290 static goldenRectangle() { | |
| 291 var PHI = (1 + Math.sqrt(5)) / 2; | |
| 292 return new Rectangle(0, 0, PHI, 1); | |
| 293 } | |
| 294 } | |
| 295 ``` | |
| 296 | |
| 297 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0/#sec-cl ass-definitions) | |
| 298 | |
| 299 **Discussion Notes / Link to Thread:** | |
| 300 | |
| 301 --- | |
| 302 | |
| 303 ## Block Scope Functions | 307 ## Block Scope Functions | 
| 304 | 308 | 
| 305 **Usage Example:** | 309 **Usage Example:** | 
| 306 | 310 | 
| 307 ```js | 311 ```js | 
| 308 { | 312 { | 
| 309 function foo() { | 313 function foo() { | 
| 310 return 1; | 314 return 1; | 
| 311 } | 315 } | 
| 312 // foo() === 1 | 316 // foo() === 1 | 
| (...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 954 | 958 | 
| 955 ```js | 959 ```js | 
| 956 // See Doc | 960 // See Doc | 
| 957 ``` | 961 ``` | 
| 958 | 962 | 
| 959 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0/#sec-ma th) | 963 **Documentation:** [link](http://www.ecma-international.org/ecma-262/6.0/#sec-ma th) | 
| 960 | 964 | 
| 961 **Discussion Notes / Link to Thread:** | 965 **Discussion Notes / Link to Thread:** | 
| 962 | 966 | 
| 963 --- | 967 --- | 
| OLD | NEW |