Source code
Revision control
Copy as Markdown
Other Tools
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
"use strict";
class CssExplainersTooltipHelper {
/**
* Fill the tooltip with container information.
*/
async setContent({ expression, pseudoElement, rule }, tooltip) {
const res = await rule.domRule.getCssExplainersData(
expression,
pseudoElement,
rule.inherited
);
const { doc } = tooltip;
const tooltipContainer = doc.createElementNS(XHTML_NS, "div");
tooltipContainer.classList.add("devtools-tooltip-css-explainers");
if (!res.length) {
tooltipContainer.append(`Couldn't compute data for "${expression}"`);
} else {
const ol = doc.createElementNS(XHTML_NS, "ol");
for (const step of res) {
const li = doc.createElementNS(XHTML_NS, "li");
li.append(step);
ol.append(li);
}
tooltipContainer.append(ol);
}
await tooltip.replaceChildrenLocalized(tooltipContainer);
}
}
module.exports = CssExplainersTooltipHelper;