|
|
@ -19,7 +19,7 @@ import { add_event_handler } from '../shared/add_event_handlers';
|
|
|
|
import { add_action } from '../shared/add_actions';
|
|
|
|
import { add_action } from '../shared/add_actions';
|
|
|
|
import bind_this from '../shared/bind_this';
|
|
|
|
import bind_this from '../shared/bind_this';
|
|
|
|
import { is_head } from '../shared/is_head';
|
|
|
|
import { is_head } from '../shared/is_head';
|
|
|
|
import { Identifier, ExpressionStatement, CallExpression } from 'estree';
|
|
|
|
import { Identifier, ExpressionStatement, CallExpression, Node } from 'estree';
|
|
|
|
import EventHandler from './EventHandler';
|
|
|
|
import EventHandler from './EventHandler';
|
|
|
|
import { extract_names } from 'periscopic';
|
|
|
|
import { extract_names } from 'periscopic';
|
|
|
|
import Action from '../../../nodes/Action';
|
|
|
|
import Action from '../../../nodes/Action';
|
|
|
@ -534,7 +534,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
.filter((attr) => !(attr instanceof SpreadAttributeWrapper) && !attr.property_name)
|
|
|
|
.filter((attr) => !(attr instanceof SpreadAttributeWrapper) && !attr.property_name)
|
|
|
|
.map((attr) => p`${(attr as StyleAttributeWrapper | AttributeWrapper).name}: true`);
|
|
|
|
.map((attr) => p`${(attr as StyleAttributeWrapper | AttributeWrapper).name}: true`);
|
|
|
|
|
|
|
|
|
|
|
|
let reference;
|
|
|
|
let reference: string | ReturnType<typeof x>;
|
|
|
|
if (this.node.tag_expr.node.type === 'Literal') {
|
|
|
|
if (this.node.tag_expr.node.type === 'Literal') {
|
|
|
|
if (this.node.namespace) {
|
|
|
|
if (this.node.namespace) {
|
|
|
|
reference = `"${this.node.tag_expr.node.value}"`;
|
|
|
|
reference = `"${this.node.tag_expr.node.value}"`;
|
|
|
@ -634,7 +634,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
// media bindings — awkward special case. The native timeupdate events
|
|
|
|
// media bindings — awkward special case. The native timeupdate events
|
|
|
|
// fire too infrequently, so we need to take matters into our
|
|
|
|
// fire too infrequently, so we need to take matters into our
|
|
|
|
// own hands
|
|
|
|
// own hands
|
|
|
|
let animation_frame;
|
|
|
|
let animation_frame: Identifier | undefined;
|
|
|
|
if (binding_group.events[0] === 'timeupdate') {
|
|
|
|
if (binding_group.events[0] === 'timeupdate') {
|
|
|
|
animation_frame = block.get_unique_name(`${this.var.name}_animationframe`);
|
|
|
|
animation_frame = block.get_unique_name(`${this.var.name}_animationframe`);
|
|
|
|
block.add_variable(animation_frame);
|
|
|
|
block.add_variable(animation_frame);
|
|
|
@ -874,9 +874,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
add_transitions(
|
|
|
|
add_transitions(block: Block) {
|
|
|
|
block: Block
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
const { intro, outro } = this.node;
|
|
|
|
const { intro, outro } = this.node;
|
|
|
|
if (!intro && !outro) return;
|
|
|
|
if (!intro && !outro) return;
|
|
|
|
|
|
|
|
|
|
|
@ -933,7 +931,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
|
|
|
|
|
|
|
|
const fn = this.renderer.reference(intro.name);
|
|
|
|
const fn = this.renderer.reference(intro.name);
|
|
|
|
|
|
|
|
|
|
|
|
let intro_block;
|
|
|
|
let intro_block: Node[];
|
|
|
|
|
|
|
|
|
|
|
|
if (outro) {
|
|
|
|
if (outro) {
|
|
|
|
intro_block = b`
|
|
|
|
intro_block = b`
|
|
|
@ -1032,7 +1030,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
${outro && b`@add_transform(${this.var}, ${rect});`}
|
|
|
|
${outro && b`@add_transform(${this.var}, ${rect});`}
|
|
|
|
`);
|
|
|
|
`);
|
|
|
|
|
|
|
|
|
|
|
|
let params;
|
|
|
|
let params: Node | ReturnType<typeof x>;
|
|
|
|
if (this.node.animation.expression) {
|
|
|
|
if (this.node.animation.expression) {
|
|
|
|
params = this.node.animation.expression.manipulate(block);
|
|
|
|
params = this.node.animation.expression.manipulate(block);
|
|
|
|
|
|
|
|
|
|
|
@ -1060,8 +1058,8 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
const has_spread = this.node.attributes.some(attr => attr.is_spread);
|
|
|
|
const has_spread = this.node.attributes.some(attr => attr.is_spread);
|
|
|
|
this.node.classes.forEach(class_directive => {
|
|
|
|
this.node.classes.forEach(class_directive => {
|
|
|
|
const { expression, name } = class_directive;
|
|
|
|
const { expression, name } = class_directive;
|
|
|
|
let snippet;
|
|
|
|
let snippet: Node | string;
|
|
|
|
let dependencies;
|
|
|
|
let dependencies: Set<string>;
|
|
|
|
if (expression) {
|
|
|
|
if (expression) {
|
|
|
|
snippet = expression.manipulate(block);
|
|
|
|
snippet = expression.manipulate(block);
|
|
|
|
dependencies = expression.dependencies;
|
|
|
|
dependencies = expression.dependencies;
|
|
|
@ -1105,7 +1103,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
const { name, expression, should_cache } = style_directive;
|
|
|
|
const { name, expression, should_cache } = style_directive;
|
|
|
|
|
|
|
|
|
|
|
|
const snippet = expression.manipulate(block);
|
|
|
|
const snippet = expression.manipulate(block);
|
|
|
|
let cached_snippet;
|
|
|
|
let cached_snippet: Identifier | undefined;
|
|
|
|
if (should_cache) {
|
|
|
|
if (should_cache) {
|
|
|
|
cached_snippet = block.get_unique_name(`style_${name.replace(regex_minus_signs, '_')}`);
|
|
|
|
cached_snippet = block.get_unique_name(`style_${name.replace(regex_minus_signs, '_')}`);
|
|
|
|
block.add_variable(cached_snippet, snippet);
|
|
|
|
block.add_variable(cached_snippet, snippet);
|
|
|
@ -1136,7 +1134,7 @@ export default class ElementWrapper extends Wrapper {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
add_manual_style_scoping(block) {
|
|
|
|
add_manual_style_scoping(block: Block) {
|
|
|
|
if (this.node.needs_manual_style_scoping) {
|
|
|
|
if (this.node.needs_manual_style_scoping) {
|
|
|
|
const updater = b`@toggle_class(${this.var}, "${this.node.component.stylesheet.id}", true);`;
|
|
|
|
const updater = b`@toggle_class(${this.var}, "${this.node.component.stylesheet.id}", true);`;
|
|
|
|
block.chunks.hydrate.push(updater);
|
|
|
|
block.chunks.hydrate.push(updater);
|
|
|
@ -1151,7 +1149,7 @@ const regex_dollar_signs = /\$/g;
|
|
|
|
function to_html(wrappers: Array<ElementWrapper | TextWrapper | MustacheTagWrapper | RawMustacheTagWrapper>, block: Block, literal: any, state: any, can_use_raw_text?: boolean) {
|
|
|
|
function to_html(wrappers: Array<ElementWrapper | TextWrapper | MustacheTagWrapper | RawMustacheTagWrapper>, block: Block, literal: any, state: any, can_use_raw_text?: boolean) {
|
|
|
|
wrappers.forEach(wrapper => {
|
|
|
|
wrappers.forEach(wrapper => {
|
|
|
|
if (wrapper instanceof TextWrapper) {
|
|
|
|
if (wrapper instanceof TextWrapper) {
|
|
|
|
// Don't add the <pre>/<textare> newline logic here because pre/textarea.innerHTML
|
|
|
|
// Don't add the <pre>/<textarea> newline logic here because pre/textarea.innerHTML
|
|
|
|
// would keep the leading newline, too, only someParent.innerHTML = '..<pre/textarea>..' won't
|
|
|
|
// would keep the leading newline, too, only someParent.innerHTML = '..<pre/textarea>..' won't
|
|
|
|
|
|
|
|
|
|
|
|
if ((wrapper as TextWrapper).use_space()) state.quasi.value.raw += ' ';
|
|
|
|
if ((wrapper as TextWrapper).use_space()) state.quasi.value.raw += ' ';
|
|
|
|