MCPcopy Create free account
hub / github.com/ampproject/amphtml / rootSelectorPrefixer

Function rootSelectorPrefixer

src/shadow-embed.js:262–272  ·  view source on GitHub ↗

* See `transformRootSelectors`. * @param {string} match * @param {string} name * @param {number} pos * @param {string} selector * @return {string} * @private

(match, name, pos, selector)

Source from the content-addressed store, hash-verified

260 * @private
261 */
262function rootSelectorPrefixer(match, name, pos, selector) {
263 const prev = selector.charAt(pos - 1);
264 const next = selector.charAt(pos + match.length);
265 if (
266 (!prev || CSS_SELECTOR_BEG_REGEX.test(prev)) &&
267 (!next || CSS_SELECTOR_END_REGEX.test(next))
268 ) {
269 return 'amp-' + match;
270 }
271 return match;
272}
273
274/**
275 * @param {!Document} doc

Callers

nothing calls this directly

Calls 1

testMethod · 0.45

Tested by

no test coverage detected