From 6a90432a3b551692361a83000a6f2b6640127cba Mon Sep 17 00:00:00 2001 From: Zibi Braniecki Date: Mon, 23 May 2016 17:30:41 -0700 Subject: [PATCH] Let setAttributes chain and use HTML for Template projects --- .tern-project | 13 +++++++++++++ src/bindings/dom.js | 1 + src/bindings/overlay.js | 6 ++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .tern-project diff --git a/.tern-project b/.tern-project new file mode 100644 index 00000000..1261fc04 --- /dev/null +++ b/.tern-project @@ -0,0 +1,13 @@ +{ + "ecmaVersion": 6, + "libs": [ + "browser", + "ecma6" + ], + "plugins": { + "node": {}, + "complete_strings": {}, + "modules": {}, + "es_modules": {} + } +} diff --git a/src/bindings/dom.js b/src/bindings/dom.js index 074660fa..c9ea9d34 100644 --- a/src/bindings/dom.js +++ b/src/bindings/dom.js @@ -13,6 +13,7 @@ export function setAttributes(element, id, args) { if (args) { element.setAttribute('data-l10n-args', JSON.stringify(args)); } + return element; } export function getAttributes(element) { diff --git a/src/bindings/overlay.js b/src/bindings/overlay.js index ec088aad..c2ef3284 100644 --- a/src/bindings/overlay.js +++ b/src/bindings/overlay.js @@ -12,6 +12,7 @@ const allowed = { global: ['title', 'aria-label', 'aria-valuetext', 'aria-moz-hint'], a: ['download'], area: ['download', 'alt'], + button: ['accesskey'], // used by XUL // value is special-cased in isAttrAllowed input: ['alt', 'placeholder'], menuitem: ['label'], @@ -34,7 +35,8 @@ export function overlayElement(element, translation) { } else { // start with an inert template element and move its children into // `element` but such that `element`'s own children are not replaced - const tmpl = element.ownerDocument.createElement('template'); + const tmpl = element.ownerDocument.createElementNS( + 'http://www.w3.org/1999/xhtml', 'template'); tmpl.innerHTML = value; // overlay the node with the DocumentFragment overlay(element, tmpl.content); @@ -155,7 +157,7 @@ function getNthElementOfType(context, element, index) { let nthOfType = 0; for (let i = 0, child; child = context.children[i]; i++) { if (child.nodeType === child.ELEMENT_NODE && - child.tagName === element.tagName) { + child.tagName.toLowerCase() === element.tagName.toLowerCase()) { if (nthOfType === index) { return child; }