Chromium Code Reviews
DescriptionBefore (for `f(a, {b, c: c_default})`):
function f(a, opts) {
let b = opts && 'b' in opts ? opts.b : null;
let c = opts && 'c' in opts ? opts.c : c_default;
...
After:
function f(a, {b = null, c = c_default} = {}) {
...
Note:
- Still reverting to old code when any parameter clashes with reserved JS names (see discussion in https://github.com/dart-lang/dev_compiler/issues/392)
- When a parameter clashes with a Object.prototype property, using a clean default opts value (Object.create(null)).
- Passing opts through in aliased constructors, both for speed/concision and correctness (since default param value semantic is weird there)
BUG=
R=jmesserly@google.com
Committed: https://github.com/dart-lang/dev_compiler/commit/c9d909ced98dea2aefe20322a59d18fbab2d93b2
Patch Set 1 #Patch Set 2 : Destructure function params directly (no more opts in most cases) #
Total comments: 30
Patch Set 3 : Use Object.create(null) and simplify destructuring logic #Patch Set 4 : test Object.create(null) behaviour in codegen #Patch Set 5 : Rename Destructuring to BindingPattern + other nits #Patch Set 6 : Drop out of destructuring when names clash with js reserved names #Patch Set 7 : Rebased + squashed in 1 commit #
Total comments: 5
Patch Set 8 : #
Messages
Total messages: 13 (6 generated)
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||