|
|
@ -1,17 +1,14 @@
|
|
|
|
/** @import { ArrayExpression, Expression, ExpressionStatement, Identifier, MemberExpression, ObjectExpression } from 'estree' */
|
|
|
|
/** @import { ArrayExpression, Expression, ExpressionStatement, Identifier, MemberExpression, ObjectExpression } from 'estree' */
|
|
|
|
/** @import { AST } from '#compiler' */
|
|
|
|
/** @import { AST } from '#compiler' */
|
|
|
|
/** @import { SourceLocation } from '#shared' */
|
|
|
|
|
|
|
|
/** @import { ComponentClientTransformState, ComponentContext } from '../types' */
|
|
|
|
/** @import { ComponentClientTransformState, ComponentContext } from '../types' */
|
|
|
|
/** @import { Scope } from '../../../scope' */
|
|
|
|
/** @import { Scope } from '../../../scope' */
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
cannot_be_set_statically,
|
|
|
|
cannot_be_set_statically,
|
|
|
|
is_boolean_attribute,
|
|
|
|
is_boolean_attribute,
|
|
|
|
is_dom_property,
|
|
|
|
is_dom_property,
|
|
|
|
is_load_error_element,
|
|
|
|
is_load_error_element
|
|
|
|
is_void
|
|
|
|
|
|
|
|
} from '../../../../../utils.js';
|
|
|
|
} from '../../../../../utils.js';
|
|
|
|
import { escape_html } from '../../../../../escaping.js';
|
|
|
|
import { is_ignored } from '../../../../state.js';
|
|
|
|
import { dev, is_ignored, locator } from '../../../../state.js';
|
|
|
|
|
|
|
|
import { is_event_attribute, is_text_attribute } from '../../../../utils/ast.js';
|
|
|
|
import { is_event_attribute, is_text_attribute } from '../../../../utils/ast.js';
|
|
|
|
import * as b from '#compiler/builders';
|
|
|
|
import * as b from '#compiler/builders';
|
|
|
|
import { is_custom_element_node } from '../../../nodes.js';
|
|
|
|
import { is_custom_element_node } from '../../../nodes.js';
|
|
|
@ -39,20 +36,9 @@ import { visit_event_attribute } from './shared/events.js';
|
|
|
|
* @param {ComponentContext} context
|
|
|
|
* @param {ComponentContext} context
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function RegularElement(node, context) {
|
|
|
|
export function RegularElement(node, context) {
|
|
|
|
/** @type {SourceLocation} */
|
|
|
|
context.state.template.create_element(node.name, node.start);
|
|
|
|
let location = [-1, -1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dev) {
|
|
|
|
|
|
|
|
const loc = locator(node.start);
|
|
|
|
|
|
|
|
if (loc) {
|
|
|
|
|
|
|
|
location[0] = loc.line;
|
|
|
|
|
|
|
|
location[1] = loc.column;
|
|
|
|
|
|
|
|
context.state.locations.push(location);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (node.name === 'noscript') {
|
|
|
|
if (node.name === 'noscript') {
|
|
|
|
context.state.template.create_element('noscript');
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -68,8 +54,6 @@ export function RegularElement(node, context) {
|
|
|
|
|
|
|
|
|
|
|
|
context.state.template.contains_script_tag ||= node.name === 'script';
|
|
|
|
context.state.template.contains_script_tag ||= node.name === 'script';
|
|
|
|
|
|
|
|
|
|
|
|
context.state.template.create_element(node.name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {Array<AST.Attribute | AST.SpreadAttribute>} */
|
|
|
|
/** @type {Array<AST.Attribute | AST.SpreadAttribute>} */
|
|
|
|
const attributes = [];
|
|
|
|
const attributes = [];
|
|
|
|
|
|
|
|
|
|
|
@ -345,7 +329,6 @@ export function RegularElement(node, context) {
|
|
|
|
const state = {
|
|
|
|
const state = {
|
|
|
|
...context.state,
|
|
|
|
...context.state,
|
|
|
|
metadata,
|
|
|
|
metadata,
|
|
|
|
locations: [],
|
|
|
|
|
|
|
|
scope: /** @type {Scope} */ (context.state.scopes.get(node.fragment)),
|
|
|
|
scope: /** @type {Scope} */ (context.state.scopes.get(node.fragment)),
|
|
|
|
preserve_whitespace:
|
|
|
|
preserve_whitespace:
|
|
|
|
context.state.preserve_whitespace || node.name === 'pre' || node.name === 'textarea'
|
|
|
|
context.state.preserve_whitespace || node.name === 'pre' || node.name === 'textarea'
|
|
|
@ -439,10 +422,6 @@ export function RegularElement(node, context) {
|
|
|
|
context.state.update.push(b.stmt(b.assignment('=', dir, dir)));
|
|
|
|
context.state.update.push(b.stmt(b.assignment('=', dir, dir)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (state.locations.length > 0) {
|
|
|
|
|
|
|
|
// @ts-expect-error
|
|
|
|
|
|
|
|
location.push(state.locations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
context.state.template.pop_element();
|
|
|
|
context.state.template.pop_element();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|