MCPcopy
hub / github.com/webpack/webpack / [NodeType.Ident]

Method [NodeType.Ident]

lib/css/CssParser.js:3577–3628  ·  view source on GitHub ↗
(node, parent)

Source from the content-addressed store, hash-verified

3575 }
3576 },
3577 [NodeType.Ident](node, parent) {
3578 // Fast exit before slicing the ident value: outside dashed-ident scoping
3579 // and ICSS context (any non-CSS-Modules stylesheet) a bare ident carries
3580 // no work, and idents are the most common node, so skipping the per-ident
3581 // `value` slice matters.
3582 const dashedActive = dashed.active;
3583 const icss = icssActive();
3584 if (!dashedActive && !icss) return;
3585 const identValue = A.value(node);
3586 if (dashedActive && isDashedIdentifier(identValue)) {
3587 // Dashed idents are scoped here, never `@value` ICSS-rewritten.
3588 if (!dashed.emit) return;
3589 // Resolve the `--foo from "./x.css"` / `--foo from global` import suffix via sibling lookahead.
3590 const siblings = childrenOf(parent);
3591 const i = siblings ? siblings.indexOf(node) : -1;
3592 if (siblings && i !== -1) {
3593 const j = nextNonWhitespace(siblings, i + 1);
3594 if (
3595 j < siblings.length &&
3596 A.type(siblings[j]) === NodeType.Ident &&
3597 equalsLowerCase(A.value(siblings[j]), "from")
3598 ) {
3599 const fromIdent = siblings[j];
3600 const sourceNode = siblings[nextNonWhitespace(siblings, j + 1)];
3601 if (
3602 sourceNode &&
3603 A.type(sourceNode) === NodeType.Ident &&
3604 A.value(sourceNode) === "global"
3605 ) {
3606 emitDashedIdentFromGlobal(A.end(node), A.end(sourceNode));
3607 return;
3608 }
3609 if (sourceNode && A.type(sourceNode) === NodeType.String) {
3610 emitDashedIdentImport(
3611 A.start(node),
3612 A.end(node),
3613 A.start(fromIdent),
3614 A.end(sourceNode),
3615 input.slice(A.start(sourceNode) + 1, A.end(sourceNode) - 1)
3616 );
3617 return;
3618 }
3619 }
3620 }
3621 emitDashedIdentExport(A.start(node), A.end(node));
3622 return;
3623 }
3624 if (!icss) return;
3625 if (icssDefinitions.has(identValue)) {
3626 emitICSSSymbol(identValue, A.start(node), A.end(node));
3627 }
3628 }
3629 };
3630 // `as` selects the top-level production (§5.3): a `style` attribute is a
3631 // block's contents, everything else a full stylesheet (the default).

Callers

nothing calls this directly

Calls 8

isDashedIdentifierFunction · 0.85
childrenOfFunction · 0.85
nextNonWhitespaceFunction · 0.85
equalsLowerCaseFunction · 0.85
sliceMethod · 0.80
valueMethod · 0.45
typeMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected