@@ -182,6 +182,7 @@ export function getScriptInfo(node: DefaultTreeAdapterMap['element']): {
182
182
let isModule = false
183
183
let isAsync = false
184
184
for ( const p of node . attrs ) {
185
+ if ( p . prefix !== undefined ) continue
185
186
if ( p . name === 'src' ) {
186
187
if ( ! src ) {
187
188
src = p
@@ -412,9 +413,10 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
412
413
const assetAttrs = assetAttrsConfig [ node . nodeName ]
413
414
if ( assetAttrs ) {
414
415
for ( const p of node . attrs ) {
415
- if ( p . value && assetAttrs . includes ( p . name ) ) {
416
+ const attrKey = getAttrKey ( p )
417
+ if ( p . value && assetAttrs . includes ( attrKey ) ) {
416
418
const attrSourceCodeLocation =
417
- node . sourceCodeLocation ! . attrs ! [ p . name ]
419
+ node . sourceCodeLocation ! . attrs ! [ attrKey ]
418
420
// assetsUrl may be encodeURI
419
421
const url = decodeURI ( p . value )
420
422
if ( ! isExcludedUrl ( url ) ) {
@@ -423,7 +425,9 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
423
425
isCSSRequest ( url ) &&
424
426
// should not be converted if following attributes are present (#6748)
425
427
! node . attrs . some (
426
- ( p ) => p . name === 'media' || p . name === 'disabled'
428
+ ( p ) =>
429
+ p . prefix === undefined &&
430
+ ( p . name === 'media' || p . name === 'disabled' )
427
431
)
428
432
) {
429
433
// CSS references, convert to import
@@ -453,7 +457,10 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
453
457
// <tag style="... url(...) ..."></tag>
454
458
// extract inline styles as virtual css and add class attribute to tag for selecting
455
459
const inlineStyle = node . attrs . find (
456
- ( prop ) => prop . name === 'style' && prop . value . includes ( 'url(' ) // only url(...) in css need to emit file
460
+ ( prop ) =>
461
+ prop . prefix === undefined &&
462
+ prop . name === 'style' &&
463
+ prop . value . includes ( 'url(' ) // only url(...) in css need to emit file
457
464
)
458
465
if ( inlineStyle ) {
459
466
inlineModuleIndex ++
@@ -527,7 +534,7 @@ export function buildHtmlPlugin(config: ResolvedConfig): Plugin {
527
534
) {
528
535
try {
529
536
const url =
530
- attr . name === 'srcset'
537
+ attr . prefix === undefined && attr . name === 'srcset'
531
538
? await processSrcSet ( content , ( { url } ) =>
532
539
urlToBuiltUrl ( url , id , config , this )
533
540
)
@@ -1133,3 +1140,7 @@ function serializeAttrs(attrs: HtmlTagDescriptor['attrs']): string {
1133
1140
function incrementIndent ( indent : string = '' ) {
1134
1141
return `${ indent } ${ indent [ 0 ] === '\t' ? '\t' : ' ' } `
1135
1142
}
1143
+
1144
+ export function getAttrKey ( attr : Token . Attribute ) : string {
1145
+ return attr . prefix === undefined ? attr . name : `${ attr . prefix } :${ attr . name } `
1146
+ }
0 commit comments