|
|
@ -6,6 +6,7 @@ import addToSet from '../../utils/addToSet';
|
|
|
|
import { DomGenerator } from '../dom/index';
|
|
|
|
import { DomGenerator } from '../dom/index';
|
|
|
|
import Node from './shared/Node';
|
|
|
|
import Node from './shared/Node';
|
|
|
|
import Element from './Element';
|
|
|
|
import Element from './Element';
|
|
|
|
|
|
|
|
import Text from './Text';
|
|
|
|
import Block from '../dom/Block';
|
|
|
|
import Block from '../dom/Block';
|
|
|
|
import Expression from './shared/Expression';
|
|
|
|
import Expression from './shared/Expression';
|
|
|
|
|
|
|
|
|
|
|
@ -22,15 +23,29 @@ export default class Attribute extends Node {
|
|
|
|
compiler: DomGenerator;
|
|
|
|
compiler: DomGenerator;
|
|
|
|
parent: Element;
|
|
|
|
parent: Element;
|
|
|
|
name: string;
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
isSpread: boolean;
|
|
|
|
isTrue: boolean;
|
|
|
|
isTrue: boolean;
|
|
|
|
isDynamic: boolean;
|
|
|
|
isDynamic: boolean;
|
|
|
|
chunks: Node[];
|
|
|
|
expression?: Expression;
|
|
|
|
|
|
|
|
chunks: (Text | Expression)[];
|
|
|
|
dependencies: Set<string>;
|
|
|
|
dependencies: Set<string>;
|
|
|
|
expression: Node;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(compiler, parent, scope, info) {
|
|
|
|
constructor(compiler, parent, scope, info) {
|
|
|
|
super(compiler, parent, scope, info);
|
|
|
|
super(compiler, parent, scope, info);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (info.type === 'Spread') {
|
|
|
|
|
|
|
|
this.name = null;
|
|
|
|
|
|
|
|
this.isSpread = true;
|
|
|
|
|
|
|
|
this.isTrue = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.expression = new Expression(compiler, this, scope, info.expression);
|
|
|
|
|
|
|
|
this.dependencies = this.expression.dependencies;
|
|
|
|
|
|
|
|
this.chunks = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.isDynamic = true; // TODO not necessarily
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
this.name = info.name;
|
|
|
|
this.name = info.name;
|
|
|
|
this.isTrue = info.value === true;
|
|
|
|
this.isTrue = info.value === true;
|
|
|
|
|
|
|
|
|
|
|
@ -47,12 +62,12 @@ export default class Attribute extends Node {
|
|
|
|
return expression;
|
|
|
|
return expression;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO this would be better, but it breaks some stuff
|
|
|
|
|
|
|
|
// this.isDynamic = this.dependencies.size > 0;
|
|
|
|
this.isDynamic = this.chunks.length === 1
|
|
|
|
this.isDynamic = this.chunks.length === 1
|
|
|
|
? this.chunks[0].type !== 'Text'
|
|
|
|
? this.chunks[0].type !== 'Text'
|
|
|
|
: this.chunks.length > 1;
|
|
|
|
: this.chunks.length > 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
// TODO this would be better, but it breaks some stuff
|
|
|
|
|
|
|
|
// this.isDynamic = this.dependencies.size > 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getValue() {
|
|
|
|
getValue() {
|
|
|
|