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); this.addBindings(block, allUsedContexts);
const eventHandlerUsesComponent = this.addEventHandlers(block, allUsedContexts); const eventHandlerUsesComponent = this.addEventHandlers(block, allUsedContexts);
this.addRefs(block); this.addRefs(block);
this.addAttributes(block);
this.addTransitions(block); this.addTransitions(block);
this.addActions(block); this.addActions(block);
if (this.attributes.find(attr => attr.type === 'Spread')) {
this.addSpreadAttributes(block);
} else {
this.addAttributes(block);
}
if (allUsedContexts.size || eventHandlerUsesComponent) { if (allUsedContexts.size || eventHandlerUsesComponent) {
const initialProps: string[] = []; const initialProps: string[] = [];
const updates: string[] = []; const updates: string[] = [];
@ -443,6 +438,11 @@ export default class Element extends Node {
} }
addAttributes(block: Block) { 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) => { this.attributes.filter((a: Attribute) => a.type === 'Attribute').forEach((attribute: Attribute) => {
attribute.render(block); attribute.render(block);
}); });
@ -609,6 +609,7 @@ export default class Element extends Node {
} }
addRefs(block: Block) { 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) => { this.attributes.filter((a: Ref) => a.type === 'Ref').forEach((attribute: Ref) => {
const ref = `#component.refs.${attribute.name}`; const ref = `#component.refs.${attribute.name}`;

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

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

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

Loading…
Cancel
Save