Bug 1453480 - Update Node.localize API to renamed attrs->attributes in fluent-dom 0.2.0. r?smaug
MozReview-Commit-ID: H47PYERTGxr
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -2733,17 +2733,17 @@ public:
elem->SetTextContent(content, rv);
if (NS_WARN_IF(rv.Failed())) {
mReturnValuePromise->MaybeRejectWithUndefined();
return;
}
}
Nullable<Sequence<AttributeNameValue>>& attributes =
- l10nData[i].mAttrs;
+ l10nData[i].mAttributes;
if (!attributes.IsNull()) {
for (size_t j = 0; j < attributes.Value().Length(); ++j) {
// Use SetAttribute here to validate the attribute name!
elem->SetAttribute(attributes.Value()[j].mName,
attributes.Value()[j].mValue,
rv);
if (rv.Failed()) {
mReturnValuePromise->MaybeRejectWithUndefined();
--- a/dom/base/test/chrome/test_node_localize.xul
+++ b/dom/base/test/chrome/test_node_localize.xul
@@ -20,35 +20,35 @@ https://bugzilla.mozilla.org/show_bug.cg
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
/** Test for Bug 1363862 **/
const translations = {
"key1": {
value: "Value 1",
- attrs: null,
+ attributes: null,
},
"key2": {
value: null,
- attrs: [
+ attributes: [
{name: "label", value: "Value 2"},
{name: "accesskey", value: "K"},
]
},
"key3": {
value: "Value 3",
- attrs: [
+ attributes: [
{name: "accesskey", value: "V"},
]
},
"key4": undefined,
"key5": {
value: null,
- attrs: [
+ attributes: [
{name: "value", value: "Submit Value"},
]
}
}
/**
* This function serves as an approximation of what Localization does.
*/
@@ -113,18 +113,18 @@ https://bugzilla.mozilla.org/show_bug.cg
continue;
}
if (translation.value !== null) {
ok(elem.textContent === translation.value,
"element's textContent should be populated with the translation value");
}
- if (translation.attrs !== null) {
- for (const {name, value} of translation.attrs) {
+ if (translation.attributes !== null) {
+ for (const {name, value} of translation.attributes) {
ok(elem.getAttribute(name) === value,
"attribute value should be populated from the translation");
}
}
}
SimpleTest.finish();
}
--- a/dom/webidl/L10nUtils.webidl
+++ b/dom/webidl/L10nUtils.webidl
@@ -26,13 +26,13 @@ dictionary L10nElement {
dictionary AttributeNameValue {
required DOMString name;
required DOMString value;
};
dictionary L10nValue {
DOMString? value = null;
- sequence<AttributeNameValue>? attrs = null;
+ sequence<AttributeNameValue>? attributes = null;
};
callback L10nCallback =
Promise<sequence<L10nValue>> (sequence<L10nElement> l10nElements);
--- a/dom/webidl/Node.webidl
+++ b/dom/webidl/Node.webidl
@@ -187,19 +187,19 @@ interface Node : EventTarget {
* l10nArgs: null,
* l10nAttrs: "title",
* name: "window"
* namespaceURI: "..."
* type: null
* },
* ]
* [2] trans == [
- * {value: "Key 1", attrs: {accesskey: "K"} },
+ * {value: "Key 1", attributes: {accesskey: "K"} },
* undefined,
- * {value: null, attrs: {title: "Unread emails: 5"} },
+ * {value: null, attributes: {title: "Unread emails: 5"} },
* ]
* [3] untranslatedElements == [
* ,
* <label>
* ,
* ]
*
* For exact dictionary structures, see `L10nUtils.webidl`.