Auto merge of #23530 - gatoWololo:omar_update_CustomElementConstructor_type, r=cybai,jdm

Use TypeError instead of InvalidState for exception.

<!-- Please describe your changes on the following line: -->
Use TypeError instead of InvalidState as per https://github.com/whatwg/html/pull/4525 for making CustomElementConstructor exceptions more consistent.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #23202  (GitHub issue number if applicable)

<!-- Either: -->
- [X] There are tests for these changes: Tests that expected failure now expect passing with correct result.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23530)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-06-08 08:15:12 -04:00 committed by GitHub
commit d72cd4df20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 29 deletions

View file

@ -182,7 +182,12 @@ where
DomRoot::downcast(element).ok_or(Error::InvalidState)
},
// Step 10
Some(ConstructionStackEntry::AlreadyConstructedMarker) => Err(Error::InvalidState),
Some(ConstructionStackEntry::AlreadyConstructedMarker) => {
let s = "Top of construction stack marked AlreadyConstructed due to \
a custom element constructor constructing itself after super()"
.to_string();
Err(Error::Type(s))
},
}
}

View file

@ -680,7 +680,9 @@ fn run_upgrade_constructor(
return Err(Error::JSFailed);
}
if !same {
return Err(Error::InvalidState);
return Err(Error::Type(
"Returned element is not SameValue as the upgraded element".to_string(),
));
}
}
Ok(())

View file

@ -13,7 +13,7 @@ interface CustomElementRegistry {
Promise<void> whenDefined(DOMString name);
};
callback CustomElementConstructor = any();
callback CustomElementConstructor = HTMLElement();
dictionary ElementDefinitionOptions {
DOMString extends;