diff --git a/devtools/server/css-logic.js b/devtools/server/css-logic.js index ca6521f14a81..6b3d3ee12fc7 100644 --- a/devtools/server/css-logic.js +++ b/devtools/server/css-logic.js @@ -32,7 +32,14 @@ const { Cc, Ci, Cu } = require("chrome"); const DevToolsUtils = require("devtools/shared/DevToolsUtils"); const nodeConstants = require("devtools/shared/dom-node-constants"); -const {l10n, isContentStylesheet, shortSource, FILTER, STATUS} = require("devtools/shared/inspector/css-logic"); +const { + getBindingElementAndPseudo, + l10n, + isContentStylesheet, + shortSource, + FILTER, + STATUS +} = require("devtools/shared/inspector/css-logic"); /** * @param {function} isInherited A function that determines if the CSS property @@ -654,21 +661,7 @@ CssLogic.getSelectors = function (domRule) { * - {DOMNode} node The non-anonymous node * - {string} pseudo One of ':before', ':after', or null. */ -CssLogic.getBindingElementAndPseudo = function (node) { - let bindingElement = node; - let pseudo = null; - if (node.nodeName == "_moz_generated_content_before") { - bindingElement = node.parentNode; - pseudo = ":before"; - } else if (node.nodeName == "_moz_generated_content_after") { - bindingElement = node.parentNode; - pseudo = ":after"; - } - return { - bindingElement: bindingElement, - pseudo: pseudo - }; -}; +CssLogic.getBindingElementAndPseudo = getBindingElementAndPseudo; /** * Get the computed style on a node. Automatically handles reading diff --git a/devtools/shared/inspector/css-logic.js b/devtools/shared/inspector/css-logic.js index 59771b879a87..1c42d7c68f06 100644 --- a/devtools/shared/inspector/css-logic.js +++ b/devtools/shared/inspector/css-logic.js @@ -471,3 +471,30 @@ function getXPath(ele) { return parts.length ? "/" + parts.reverse().join("/") : ""; } exports.getXPath = getXPath; + +/** + * Given a node, check to see if it is a ::before or ::after element. + * If so, return the node that is accessible from within the document + * (the parent of the anonymous node), along with which pseudo element + * it was. Otherwise, return the node itself. + * + * @returns {Object} + * - {DOMNode} node The non-anonymous node + * - {string} pseudo One of ':before', ':after', or null. + */ +function getBindingElementAndPseudo(node) { + let bindingElement = node; + let pseudo = null; + if (node.nodeName == "_moz_generated_content_before") { + bindingElement = node.parentNode; + pseudo = ":before"; + } else if (node.nodeName == "_moz_generated_content_after") { + bindingElement = node.parentNode; + pseudo = ":after"; + } + return { + bindingElement: bindingElement, + pseudo: pseudo + }; +} +exports.getBindingElementAndPseudo = getBindingElementAndPseudo;