MCPcopy
hub / github.com/vitejs/vite / findNeedTransformStyleAttribute

Function findNeedTransformStyleAttribute

packages/vite/src/node/plugins/html.ts:1091–1104  ·  view source on GitHub ↗
(
  node: DefaultTreeAdapterMap['element'],
)

Source from the content-addressed store, hash-verified

1089// <tag style="... url(...) or image-set(...) ..."></tag>
1090// extract inline styles as virtual css
1091export function findNeedTransformStyleAttribute(
1092 node: DefaultTreeAdapterMap['element'],
1093): { attr: Token.Attribute; location?: Token.Location } | undefined {
1094 const attr = node.attrs.find(
1095 (prop) =>
1096 prop.prefix === undefined &&
1097 prop.name === 'style' &&
1098 // only url(...) or image-set(...) in css need to emit file
1099 (prop.value.includes('url(') || prop.value.includes('image-set(')),
1100 )
1101 if (!attr) return undefined
1102 const location = node.sourceCodeLocation?.attrs?.style
1103 return { attr, location }
1104}
1105
1106export function extractImportExpressionFromClassicScript(
1107 scriptTextNode: DefaultTreeAdapterMap['textNode'],

Callers 2

devHtmlHookFunction · 0.90
handlerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected