Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upTreat 'undefined' passed to optional JS arguments as missing #8854
Conversation
|
@bors-servo try |
Treat undefined arguments in JS 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 whehther the argument exists at all. Essentially, this is now treating undefined arguments the same as missing arguments. Fixes #8813. Fixes #6558.
|
@bors-servo try |
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 -->
|
|
Looking good here! |
Caused a regression here but instead fixed 2 tests in its place. |
|
The regression is actually REALLY weird - when a dictionary with an explicit undefined y value is used to instantiate a Is this perhaps a spec issue? |
|
Filed the regression as w3c/csswg-test#968. |
|
Are we on the rust-mozjs version that checks the argument count yet? In that case we end up checking that twice here. |
|
I don't think so, I think we're on 0.1.1 and those changes servo/components/servo/Cargo.lock Line 1525 in 7d9a6a8 |
|
Actually we're using rust-mozjs as a git dependency and we're on tip of master. |
|
Yeah, you're right. Disregard my previous comment. |
| @@ -1164,6 +1164,9 @@ def __init__(self, argument, index, args, argc, descriptorProvider, | |||
|
|
|||
| if not argument.variadic: | |||
| if argument.optional: | |||
| # Treat undefined arguments as missing | |||
| undefined_condition = string.Template("!${args}.get(${index}).is_undefined()").substitute(replacer) | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
KiChjang
Dec 6, 2015
Author
Member
Should I also change all other function calls to .get() to instead use .index()?
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
KiChjang
Dec 6, 2015
Author
Member
Wait a sec - Ms2ger's commit here made a better version of the .get() method. Do you still think I should use .index() instead?
This comment has been minimized.
This comment has been minimized.
frewsxcv
Dec 6, 2015
Member
Either use .get() solely here, or change your existing code to use index()
This comment has been minimized.
This comment has been minimized.
KiChjang
Dec 6, 2015
Author
Member
.get() returns an undefined value when it is called on a missing argument, whereas .index() will fail because of the assert!. I guess I'll stick with .get() here.
Which means I'll have to remove the previous definition of condition up there, since it's doing double-checking of parameters.
|
Using
|
|
I've also updated the PR to remove some failing expectations and removed the line where we were doing double-checking against argument counts. Note that currently it won't land because of the CSSWG test issue. |
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 -->
|
@bors-servo try |
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 -->
|
|
What is this? |
|
@bors-servo retry |
|
|
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 -->
|
|
|
components/script/dom/bindings/codegen/CodegenRust.py, line 1168 [r1] (raw file): Another consideration here would be to link to the spec (step 10.4) Comments from the review on Reviewable.io |
|
Looks good to me. Anyone else have thoughts on this? |
|
Review status: 0 of 15 files reviewed at latest revision, 1 unresolved discussion. components/script/dom/bindings/codegen/CodegenRust.py, line 1168 [r1] (raw file): Comments from the review on Reviewable.io |
|
@bors-servo delegate=KiChjang r=me once you fix that conditional |
|
|
|
@bors-servo 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 -->
|
|
KiChjang commentedDec 6, 2015
@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.