Bug 1306937 - use XHTML NS by default when creating highlighter nodes;r=pbro
MozReview-Commit-ID: 6OI5AzfWlD6
--- a/devtools/server/actors/highlighters/utils/markup.js
+++ b/devtools/server/actors/highlighters/utils/markup.js
@@ -29,16 +29,17 @@ exports.addPseudoClassLock = (...args) =
exports.removePseudoClassLock = (...args) =>
lazyContainer.DOMUtils.removePseudoClassLock(...args);
exports.getCSSStyleRules = (...args) =>
lazyContainer.DOMUtils.getCSSStyleRules(...args);
const SVG_NS = "http://www.w3.org/2000/svg";
+const XHTML_NS = "http://www.w3.org/1999/xhtml";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
const STYLESHEET_URI = "resource://devtools/server/actors/" +
"highlighters.css";
// How high is the infobar (px).
const INFOBAR_HEIGHT = 34;
// What's the size of the infobar arrow (px).
const INFOBAR_ARROW_SIZE = 9;
@@ -176,33 +177,28 @@ function createSVGNode(win, options) {
}
exports.createSVGNode = createSVGNode;
/**
* Helper function that creates DOM nodes.
* @param {Window} This window's document will be used to create the element
* @param {Object} Options for the node include:
* - nodeType: the type of node, defaults to "div".
- * - namespace: if passed, doc.createElementNS will be used instead of
- * doc.creatElement.
+ * - namespace: the namespace to use to create the node, defaults to XHTML namespace.
* - attributes: a {name:value} object to be used as attributes for the node.
* - prefix: a string that will be used to prefix the values of the id and class
* attributes.
* - parent: if provided, the newly created element will be appended to this
* node.
*/
function createNode(win, options) {
let type = options.nodeType || "div";
+ let namespace = options.namespace || XHTML_NS;
- let node;
- if (options.namespace) {
- node = win.document.createElementNS(options.namespace, type);
- } else {
- node = win.document.createElement(type);
- }
+ let node = win.document.createElementNS(namespace, type);
for (let name in options.attributes || {}) {
let value = options.attributes[name];
if (options.prefix && (name === "class" || name === "id")) {
value = options.prefix + value;
}
node.setAttribute(name, value);
}