diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2015-12-13 10:41:56 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2015-12-13 10:41:56 +0530 |
commit | 8bab1cd7a4634618d18985d273c6997984919ecc (patch) | |
tree | 7c1574b2aa0aa67d528d47aa13bb5563fbbfb0c0 /components/script | |
parent | e493a0655e69c1472a53708d213fd102decc59cb (diff) | |
parent | db92a8b0303c2955e8f569418ffdf748381a4b68 (diff) | |
download | servo-8bab1cd7a4634618d18985d273c6997984919ecc.tar.gz servo-8bab1cd7a4634618d18985d273c6997984919ecc.zip |
Auto merge of #8854 - KiChjang:undefined-as-missing, r=frewsxcv
Treat 'undefined' passed to optional JS arguments as missing
@frewsxcv please don't hurt me for this.
I've added an AND condition to check whether the value being passed is undefined while checking whether the argument exists at all. Essentially, this is now treating undefined arguments the same as missing arguments.
Fixes #8813.
Fixes #6558.
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8854)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/bindings/codegen/CodegenRust.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index c714bddb983..f947b0b2f80 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -1142,7 +1142,6 @@ class CGArgumentConverter(CGThing): "argc": argc, "args": args } - condition = string.Template("${index} < ${argc}").substitute(replacer) replacementVariables = { "val": string.Template("${args}.get(${index})").substitute(replacer), @@ -1164,17 +1163,18 @@ class CGArgumentConverter(CGThing): if not argument.variadic: if argument.optional: + condition = "{args}.get({index}).is_undefined()".format(**replacer) if argument.defaultValue: assert default template = CGIfElseWrapper(condition, - CGGeneric(template), - CGGeneric(default)).define() + CGGeneric(default), + CGGeneric(template)).define() else: assert not default declType = CGWrapper(declType, pre="Option<", post=">") template = CGIfElseWrapper(condition, - CGGeneric("Some(%s)" % template), - CGGeneric("None")).define() + CGGeneric("None"), + CGGeneric("Some(%s)" % template)).define() else: assert not default |