Lint and format src/compiler/compile/nodes/Animation.js

pull/8569/head
Simon Holthausen 3 years ago
parent f745d35084
commit ba6bc462ae

@ -4,48 +4,43 @@ import compiler_errors from '../compiler_errors.js';
/** @extends Node */ /** @extends Node */
export default class Animation extends Node { export default class Animation extends Node {
/** @type {'Animation'} */
/** @type {'Animation'} */ type;
type;
/** @type {string} */
/** @type {string} */ name;
name;
/** @type {import('./shared/Expression.js').default} */
/** @type {import('./shared/Expression.js').default} */ expression;
expression;
/**
/** * @param {import('../Component.js').default} component *
* @param {import('../Component.js').default} component * * @param {import('./Element.js').default} parent *
* @param {import('./Element.js').default} parent * * @param {import('./shared/TemplateScope.js').default} scope *
* @param {import('./shared/TemplateScope.js').default} scope * * @param {import('../../interfaces.js').TemplateNode} info undefined
* @param {import('../../interfaces.js').TemplateNode} info undefined */
*/ constructor(component, parent, scope, info) {
constructor(component, parent, scope, info) { super(component, parent, scope, info);
super(component, parent, scope, info); component.warn_if_undefined(info.name, info, scope);
component.warn_if_undefined(info.name, info, scope); this.name = info.name;
this.name = info.name; component.add_reference(/** @type {any} */ (this), info.name.split('.')[0]);
component.add_reference(/** @type {any} */ (this), info.name.split('.')[0]); if (parent.animation) {
if (parent.animation) { component.error(this, compiler_errors.duplicate_animation);
component.error(this, compiler_errors.duplicate_animation); return;
return; }
} const block = parent.parent;
const block = parent.parent; if (!block || block.type !== 'EachBlock') {
if (!block || block.type !== 'EachBlock') { // TODO can we relax the 'immediate child' rule?
// TODO can we relax the 'immediate child' rule? component.error(this, compiler_errors.invalid_animation_immediate);
component.error(this, compiler_errors.invalid_animation_immediate); return;
return; }
} if (!block.key) {
if (!block.key) { component.error(this, compiler_errors.invalid_animation_key);
component.error(this, compiler_errors.invalid_animation_key); return;
return; }
} /** @type {import('./EachBlock.js').default} */ (block).has_animation = true;
( /** @type {import('./EachBlock.js').default} */(block)).has_animation = true; this.expression = info.expression
this.expression = info.expression ? new Expression(component, this, scope, info.expression, true)
? new Expression(component, this, scope, info.expression, true) : null;
: null; }
}
} }

Loading…
Cancel
Save