@ -9,7 +9,6 @@ import {
extract _identifiers ,
extract _identifiers ,
get _parent ,
get _parent ,
is _expression _attribute ,
is _expression _attribute ,
is _quoted _attribute ,
is _text _attribute ,
is _text _attribute ,
object ,
object ,
unwrap _optional
unwrap _optional
@ -34,6 +33,17 @@ import { Scope, get_rune } from '../scope.js';
import { merge } from '../visitors.js' ;
import { merge } from '../visitors.js' ;
import { a11y _validators } from './a11y.js' ;
import { a11y _validators } from './a11y.js' ;
/** @param {import('#compiler').Attribute} attribute */
function validate _attribute ( attribute ) {
if ( attribute . value === true || attribute . value . length === 1 ) return ;
const is _quoted = attribute . value . at ( - 1 ) ? . end !== attribute . end ;
if ( ! is _quoted ) {
e . attribute _unquoted _sequence ( attribute ) ;
}
}
/ * *
/ * *
* @ param { import ( '#compiler' ) . Component | import ( '#compiler' ) . SvelteComponent | import ( '#compiler' ) . SvelteSelf } node
* @ param { import ( '#compiler' ) . Component | import ( '#compiler' ) . SvelteComponent | import ( '#compiler' ) . SvelteSelf } node
* @ param { import ( 'zimmerframe' ) . Context < import ( '#compiler' ) . SvelteNode , import ( './types.js' ) . AnalysisState > } context
* @ param { import ( 'zimmerframe' ) . Context < import ( '#compiler' ) . SvelteNode , import ( './types.js' ) . AnalysisState > } context
@ -58,16 +68,10 @@ function validate_component(node, context) {
}
}
if ( attribute . type === 'Attribute' ) {
if ( attribute . type === 'Attribute' ) {
if (
if ( context . state . analysis . runes ) {
context . state . analysis . runes &&
validate _attribute ( attribute ) ;
! is _quoted _attribute ( attribute ) &&
Array . isArray ( attribute . value ) &&
attribute . value . length > 1
) {
e . attribute _invalid _expression ( attribute ) ;
}
if ( context . state . analysis . runes && is _expression _attribute ( attribute ) ) {
if ( is _expression _attribute ( attribute ) ) {
const expression = attribute . value [ 0 ] . expression ;
const expression = attribute . value [ 0 ] . expression ;
if ( expression . type === 'SequenceExpression' ) {
if ( expression . type === 'SequenceExpression' ) {
let i = /** @type {number} */ ( expression . start ) ;
let i = /** @type {number} */ ( expression . start ) ;
@ -78,6 +82,7 @@ function validate_component(node, context) {
}
}
}
}
}
}
}
validate _attribute _name ( attribute ) ;
validate _attribute _name ( attribute ) ;
@ -116,16 +121,10 @@ function validate_element(node, context) {
if ( attribute . type === 'Attribute' ) {
if ( attribute . type === 'Attribute' ) {
const is _expression = is _expression _attribute ( attribute ) ;
const is _expression = is _expression _attribute ( attribute ) ;
if (
if ( context . state . analysis . runes ) {
context . state . analysis . runes &&
validate _attribute ( attribute ) ;
! is _quoted _attribute ( attribute ) &&
Array . isArray ( attribute . value ) &&
attribute . value . length > 1
) {
e . attribute _invalid _expression ( attribute ) ;
}
if ( context . state . analysis . runes && is _expression ) {
if ( is _expression ) {
const expression = attribute . value [ 0 ] . expression ;
const expression = attribute . value [ 0 ] . expression ;
if ( expression . type === 'SequenceExpression' ) {
if ( expression . type === 'SequenceExpression' ) {
let i = /** @type {number} */ ( expression . start ) ;
let i = /** @type {number} */ ( expression . start ) ;
@ -136,6 +135,7 @@ function validate_element(node, context) {
}
}
}
}
}
}
}
if ( regex _illegal _attribute _character . test ( attribute . name ) ) {
if ( regex _illegal _attribute _character . test ( attribute . name ) ) {
e . attribute _invalid _name ( attribute , attribute . name ) ;
e . attribute _invalid _name ( attribute , attribute . name ) ;