@@ -583,19 +583,24 @@ function* generateReferencesForElements(
583
583
&& prop . name === 'ref'
584
584
&& prop . value
585
585
) {
586
+ const [ content , startOffset ] = normalizeAttributeValue ( prop . value ) ;
587
+
586
588
yield `// @ts-ignore${ newLine } ` ;
587
- yield * generateInterpolation (
589
+ yield `__VLS_ctx` ;
590
+ yield * generatePropertyAccess (
588
591
options ,
589
592
ctx ,
590
- prop . value . content ,
591
- prop . value . loc ,
592
- prop . value . loc . start . offset + 1 ,
593
+ content ,
594
+ startOffset ,
593
595
ctx . codeFeatures . navigation ,
594
- '(' ,
595
- ')'
596
+ prop . value . loc
596
597
) ;
597
598
yield endOfLine ;
598
599
600
+ if ( variableNameRegex . test ( content ) ) {
601
+ ctx . accessExternalVariable ( content , startOffset ) ;
602
+ }
603
+
599
604
const refName = CompilerDOM . toValidAssetId ( prop . value . content , '_VLS_refs' as any ) ;
600
605
options . templateRefNames . set ( prop . value . content , refName ) ;
601
606
return refName ;
@@ -631,16 +636,8 @@ function* generateReferencesForScopedCssClasses(
631
636
}
632
637
}
633
638
else {
634
- let startOffset = prop . value . loc . start . offset ;
635
- let content = prop . value . loc . source ;
636
639
let isWrapped = false ;
637
- if (
638
- ( content . startsWith ( `'` ) && content . endsWith ( `'` ) )
639
- || ( content . startsWith ( `"` ) && content . endsWith ( `"` ) )
640
- ) {
641
- content = content . slice ( 1 , - 1 ) ;
642
- isWrapped = true ;
643
- }
640
+ const [ content , startOffset ] = normalizeAttributeValue ( prop . value ) ;
644
641
if ( content ) {
645
642
const classes = collectClasses ( content , startOffset + ( isWrapped ? 1 : 0 ) ) ;
646
643
ctx . scopedClasses . push ( ...classes ) ;
@@ -746,6 +743,19 @@ function getTagRenameApply(oldName: string) {
746
743
return oldName === hyphenateTag ( oldName ) ? hyphenateTag : undefined ;
747
744
}
748
745
746
+ function normalizeAttributeValue ( node : CompilerDOM . TextNode ) : [ string , number ] {
747
+ let offset = node . loc . start . offset ;
748
+ let content = node . loc . source ;
749
+ if (
750
+ ( content . startsWith ( `'` ) && content . endsWith ( `'` ) )
751
+ || ( content . startsWith ( `"` ) && content . endsWith ( `"` ) )
752
+ ) {
753
+ offset ++ ;
754
+ content = content . slice ( 1 , - 1 ) ;
755
+ }
756
+ return [ content , offset ] ;
757
+ }
758
+
749
759
function collectClasses ( content : string , startOffset = 0 ) {
750
760
const classes : {
751
761
source : string ;
0 commit comments