summaryrefslogtreecommitdiffstats
path: root/dom/base/CustomElementRegistry.cpp
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-22 23:06:22 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-26 15:50:51 -0500
commite8f95f974fd378421f9ef1bbffd818ca2eae7c25 (patch)
tree5c6c062676da71877d39c1252b9808449ebe8eff /dom/base/CustomElementRegistry.cpp
parent53319e5df69201d41cbd07419aad40f37418dd02 (diff)
downloadUXP-e8f95f974fd378421f9ef1bbffd818ca2eae7c25.tar
UXP-e8f95f974fd378421f9ef1bbffd818ca2eae7c25.tar.gz
UXP-e8f95f974fd378421f9ef1bbffd818ca2eae7c25.tar.lz
UXP-e8f95f974fd378421f9ef1bbffd818ca2eae7c25.tar.xz
UXP-e8f95f974fd378421f9ef1bbffd818ca2eae7c25.zip
Bug 1413815 - Convert 'observedAttributes' to a sequence<DOMString>
Tag UXP Issue #1344
Diffstat (limited to 'dom/base/CustomElementRegistry.cpp')
-rw-r--r--dom/base/CustomElementRegistry.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp
index c52d2cc98..4a803b710 100644
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -699,7 +699,6 @@ CustomElementRegistry::Define(const nsAString& aName,
* observedAttributesIterable to a sequence<DOMString>. Rethrow
* any exceptions from the conversion.
*/
- // TODO: Bug 1293921 - Implement connected/disconnected/adopted/attributeChanged lifecycle callbacks for custom elements
if (callbacksHolder->mAttributeChangedCallback.WasPassed()) {
// Enter constructor's compartment.
JSAutoCompartment ac(cx, constructor);
@@ -712,12 +711,22 @@ CustomElementRegistry::Define(const nsAString& aName,
}
if (!observedAttributesIterable.isUndefined()) {
+ if (!observedAttributesIterable.isObject()) {
+ aRv.ThrowTypeError<MSG_NOT_SEQUENCE>(NS_LITERAL_STRING("observedAttributes"));
+ return;
+ }
+
JS::ForOfIterator iter(cx);
- if (!iter.init(observedAttributesIterable)) {
+ if (!iter.init(observedAttributesIterable, JS::ForOfIterator::AllowNonIterable)) {
aRv.StealExceptionFromJSContext(cx);
return;
}
+ if (!iter.valueIsIterable()) {
+ aRv.ThrowTypeError<MSG_NOT_SEQUENCE>(NS_LITERAL_STRING("observedAttributes"));
+ return;
+ }
+
JS::Rooted<JS::Value> attribute(cx);
while (true) {
bool done;
@@ -729,9 +738,8 @@ CustomElementRegistry::Define(const nsAString& aName,
break;
}
- JSString *attrJSStr = attribute.toString();
- nsAutoJSString attrStr;
- if (!attrStr.init(cx, attrJSStr)) {
+ nsAutoString attrStr;
+ if (!ConvertJSValueToString(cx, attribute, eStringify, eStringify, attrStr)) {
aRv.StealExceptionFromJSContext(cx);
return;
}