tidy up/notes to self

pull/1289/head
Rich-Harris 8 years ago
parent 8813ee3b0f
commit 5a45b0e7b4

@ -246,15 +246,10 @@ export default class Element extends Node {
this.addBindings(block, allUsedContexts);
const eventHandlerUsesComponent = this.addEventHandlers(block, allUsedContexts);
this.addRefs(block);
this.addAttributes(block);
this.addTransitions(block);
this.addActions(block);
if (this.attributes.find(attr => attr.type === 'Spread')) {
this.addSpreadAttributes(block);
} else {
this.addAttributes(block);
}
if (allUsedContexts.size || eventHandlerUsesComponent) {
const initialProps: string[] = [];
const updates: string[] = [];
@ -443,6 +438,11 @@ export default class Element extends Node {
}
addAttributes(block: Block) {
if (this.attributes.find(attr => attr.type === 'Spread')) {
this.addSpreadAttributes(block);
return;
}
this.attributes.filter((a: Attribute) => a.type === 'Attribute').forEach((attribute: Attribute) => {
attribute.render(block);
});
@ -609,6 +609,7 @@ export default class Element extends Node {
}
addRefs(block: Block) {
// TODO it should surely be an error to have more than one ref
this.attributes.filter((a: Ref) => a.type === 'Ref').forEach((attribute: Ref) => {
const ref = `#component.refs.${attribute.name}`;

@ -36,6 +36,7 @@ export default function visitElement(
}
if (node.attributes.find(attr => attr.type === 'Spread')) {
// TODO dry this out
const args = [];
node.attributes.forEach((attribute: Node) => {
if (attribute.type === 'Spread') {

@ -1,6 +1,4 @@
export default {
solo: true,
data: {
props: {
foo: 'lol',

@ -1,6 +1,4 @@
export default {
solo: true,
html: `<div data-named="value" data-foo="bar">red</div>`,
test ( assert, component, target ) {

Loading…
Cancel
Save