@wordpress/block-editor
Version:
40 lines (31 loc) • 954 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
/**
* @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector.
*/
const IS_ROOT_TAG = /^(body|html|:root).*$/;
const wrap = (namespace, ignore = []) => node => {
const updateSelector = selector => {
if (ignore.includes(selector.trim())) {
return selector;
} // Anything other than a root tag is always prefixed.
{
if (!selector.match(IS_ROOT_TAG)) {
return namespace + ' ' + selector;
}
} // HTML and Body elements cannot be contained within our container so lets extract their styles.
return selector.replace(/^(body|html|:root)/, namespace);
};
if (node.type === 'rule') {
return { ...node,
selectors: node.selectors.map(updateSelector)
};
}
return node;
};
var _default = wrap;
exports.default = _default;
//# sourceMappingURL=wrap.js.map