Skip to content

Commit

Permalink
missed a few
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Sep 3, 2017
1 parent 2c8268b commit 822f070
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/generators/dom/visitors/Element/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,29 +80,29 @@ export default function visitElement(
if (generator.hydratable) {
block.builders.claim.addBlock(deindent`
${name} = ${getClaimStatement(generator, childState.namespace, state.parentNodes, node)};
var ${childState.parentNodes} = @children( ${name} );
var ${childState.parentNodes} = @children(${name});
`);
}

if (parentNode) {
block.builders.mount.addLine(
`@appendNode( ${name}, ${parentNode} );`
`@appendNode(${name}, ${parentNode});`
);
} else {
block.builders.mount.addLine(`@insertNode( ${name}, #target, anchor );`);
block.builders.mount.addLine(`@insertNode(${name}, #target, anchor);`);
}

// add CSS encapsulation attribute
// TODO add a helper for this, rather than repeating it
if (node._needsCssAttribute && !generator.customElement) {
generator.needsEncapsulateHelper = true;
block.builders.hydrate.addLine(
`@encapsulateStyles( ${name} );`
`@encapsulateStyles(${name});`
);

if (node._cssRefAttribute) {
block.builders.hydrate.addLine(
`@setAttribute( ${name}, 'svelte-ref-${node._cssRefAttribute}', '' );`
`@setAttribute(${name}, "svelte-ref-${node._cssRefAttribute}", ");`
)
}
}
Expand Down Expand Up @@ -165,7 +165,7 @@ export default function visitElement(
if (isToplevel) {
// TODO we eventually need to consider what happens to elements
// that belong to the same outgroup as an outroing element...
block.builders.unmount.addLine(`@detachNode( ${name} );`);
block.builders.unmount.addLine(`@detachNode(${name});`);
}

if (node.name !== 'select') {
Expand Down Expand Up @@ -218,7 +218,7 @@ export default function visitElement(
}

block.builders.claim.addLine(
`${childState.parentNodes}.forEach( @detachNode );`
`${childState.parentNodes}.forEach(@detachNode);`
);
}

Expand All @@ -228,14 +228,14 @@ function getRenderStatement(
name: string
) {
if (namespace === 'http://www.w3.org/2000/svg') {
return `@createSvgElement( '${name}' )`;
return `@createSvgElement("${name}")`;
}

if (namespace) {
return `document.createElementNS( '${namespace}', '${name}' )`;
return `document.createElementNS("${namespace}", "${name}")`;
}

return `@createElement( '${name}' )`;
return `@createElement("${name}")`;
}

function getClaimStatement(
Expand All @@ -251,12 +251,12 @@ function getClaimStatement(

const name = namespace ? node.name : node.name.toUpperCase();

return `@claimElement( ${nodes}, '${name}', ${attributes
return `@claimElement(${nodes}, "${name}", ${attributes
? `{ ${attributes} }`
: `{}`}, ${namespace === namespaces.svg ? true : false} )`;
: `{}`}, ${namespace === namespaces.svg ? true : false})`;
}

function quoteProp(name: string) {
if (/[^a-zA-Z_$0-9]/.test(name)) return `'${name}'`;
if (/[^a-zA-Z_$0-9]/.test(name)) return `"${name}"`;
return name;
}

0 comments on commit 822f070

Please sign in to comment.