Bug 1181837 - 8 - Include inspector's head.js in markup view to remove duplication; r=bgrins

This commit is contained in:
Patrick Brosset
2016-01-20 09:42:16 +01:00
parent 9554adfc97
commit 5781119d46
75 changed files with 274 additions and 471 deletions

View File

@@ -148,42 +148,6 @@ addMessageListener("devtools:test:setStyle", function(msg) {
sendAsyncMessage("devtools:test:setStyle");
});
/**
* Get information about a DOM element, identified by a selector.
* @param {Object} data
* - {String} selector The CSS selector to get the node (can be a "super"
* selector).
* @return {Object} data Null if selector didn't match any node, otherwise:
* - {String} tagName.
* - {String} namespaceURI.
* - {Number} numChildren The number of children in the element.
* - {Array} attributes An array of {name, value, namespaceURI} objects.
* - {String} outerHTML.
* - {String} innerHTML.
* - {String} textContent.
*/
addMessageListener("devtools:test:getDomElementInfo", function(msg) {
let {selector} = msg.data;
let node = superQuerySelector(selector);
let info = null;
if (node) {
info = {
tagName: node.tagName,
namespaceURI: node.namespaceURI,
numChildren: node.children.length,
attributes: [...node.attributes].map(({name, value, namespaceURI}) => {
return {name, value, namespaceURI};
}),
outerHTML: node.outerHTML,
innerHTML: node.innerHTML,
textContent: node.textContent
};
}
sendAsyncMessage("devtools:test:getDomElementInfo", info);
});
/**
* Set a given attribute value on a node.
* @param {Object} data