GWicke has submitted this change and it was merged.
Change subject: Update HTML5.TreeBuilder.copyAttributeToElement to handle DOM 4
API.
......................................................................
Update HTML5.TreeBuilder.copyAttributeToElement to handle DOM 4 API.
setAttributeNode is deprecated in DOM 4; we use setAttribute() instead.
Change-Id: I8bdfb726df3780e885eaba55e4e685228cdc82e7
---
M js/lib/html5/treebuilder.js
1 file changed, 22 insertions(+), 6 deletions(-)
Approvals:
GWicke: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/js/lib/html5/treebuilder.js b/js/lib/html5/treebuilder.js
index bd555a7..e09e76f 100644
--- a/js/lib/html5/treebuilder.js
+++ b/js/lib/html5/treebuilder.js
@@ -13,18 +13,34 @@
}
b.prototype.copyAttributeToElement = function(element, attribute) {
+ // attributes don't inherit from Node any longer in DOM level 4
if(attribute.nodeType && attribute.nodeType ==
attribute.ATTRIBUTE_NODE) {
+ // DOM 3
element.setAttributeNode(attribute.cloneNode());
- } else {
- try {
- element.setAttribute(attribute.nodeName, attribute.nodeValue)
- } catch(e) {
- console.log("Can't set attribute '" + attribute.nodeName + "' to
value '" + attribute.nodeValue + "': (" + e + ')');
- }
if(attribute.namespace) {
var at = element.getAttributeNode(attribute.nodeName);
at.namespace = attribute.namespace;
}
+ } else {
+ try {
+ var name, value, namespace;
+ if ('namespaceURI' in attribute) { // DOM 4
+ name = attribute.name;
+ value = attribute.value;
+ namespace = attribute.namespaceURI;
+ } else { // token
+ name = attribute.nodeName;
+ value = attribute.nodeValue;
+ namespace = attribute.namespace;
+ }
+ if (namespace) {
+ element.setAttributeNS(namespace, name, value);
+ } else {
+ element.setAttribute(name, value);
+ }
+ } catch(e) {
+ console.log("Can't set attribute '" + attribute.name +
"' to value '" + attribute.value + "': (" + e + ')');
+ }
}
}
--
To view, visit https://gerrit.wikimedia.org/r/49496
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8bdfb726df3780e885eaba55e4e685228cdc82e7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Cscott <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits