@@ -499,32 +499,6 @@ export function isVoidElement(tagName: string): boolean {
499499 return HTML_VOID_ELEMENTS . has ( tagName . toLowerCase ( ) )
500500}
501501
502- export function findElementAttribute ( node : HTMLElementNode , name : string ) : HTMLAttributeNode | null {
503- if ( isERBOpenTagNode ( node . open_tag ) ) {
504- return findAttributeByName ( node . open_tag . children , name )
505- }
506-
507- return getAttribute ( node , name )
508- }
509-
510- const NON_JS_SCRIPT_TYPES = new Set ( [
511- "application/json" ,
512- "application/ld+json" ,
513- "text/template" ,
514- "text/html" ,
515- "text/x-template" ,
516- ] )
517-
518- export function isJavaScriptTag ( node : HTMLElementNode ) : boolean {
519- const typeAttribute = findElementAttribute ( node , "type" )
520- if ( ! typeAttribute ) return true
521-
522- const typeValue = getStaticAttributeValue ( typeAttribute )
523- if ( typeValue === null ) return true
524-
525- return ! NON_JS_SCRIPT_TYPES . has ( typeValue . toLowerCase ( ) )
526- }
527-
528502/**
529503 * Attribute visitor that provides granular processing based on both
530504 * attribute name type (static/dynamic) and value type (static/dynamic)
@@ -1090,3 +1064,29 @@ export function findNodeAtPosition(root: Node, line: number, column: number, pre
10901064
10911065 return bestMatch
10921066}
1067+
1068+ export function findElementAttribute ( node : HTMLElementNode , name : string ) : HTMLAttributeNode | null {
1069+ if ( isERBOpenTagNode ( node . open_tag ) ) {
1070+ return findAttributeByName ( node . open_tag . children , name )
1071+ }
1072+
1073+ return getAttribute ( node , name )
1074+ }
1075+
1076+ const NON_JS_SCRIPT_TYPES = new Set ( [
1077+ "application/json" ,
1078+ "application/ld+json" ,
1079+ "text/template" ,
1080+ "text/html" ,
1081+ "text/x-template" ,
1082+ ] )
1083+
1084+ export function isJavaScriptTagElement ( node : HTMLElementNode ) : boolean {
1085+ const typeAttribute = findElementAttribute ( node , "type" )
1086+ if ( ! typeAttribute ) return true
1087+
1088+ const typeValue = getStaticAttributeValue ( typeAttribute )
1089+ if ( typeValue === null ) return true
1090+
1091+ return ! NON_JS_SCRIPT_TYPES . has ( typeValue . toLowerCase ( ) )
1092+ }
0 commit comments