use #foo instead of block.alias("foo")

pull/673/head
Rich Harris 8 years ago
parent 9feee3a0bf
commit 334772a11d

@ -367,6 +367,8 @@ export default class Block {
${properties} ${properties}
}; };
} }
`; `.replace(/(\\)?#(\w*)/g, (match, escaped, name) => {
return escaped ? match.slice(1) : this.alias(name);
});
} }
} }

@ -4,6 +4,7 @@ import annotateWithScopes from '../../utils/annotateWithScopes';
import isReference from '../../utils/isReference'; import isReference from '../../utils/isReference';
import { walk } from 'estree-walker'; import { walk } from 'estree-walker';
import deindent from '../../utils/deindent'; import deindent from '../../utils/deindent';
import stringify from '../../utils/stringify';
import CodeBuilder from '../../utils/CodeBuilder'; import CodeBuilder from '../../utils/CodeBuilder';
import visit from './visit'; import visit from './visit';
import shared from './shared'; import shared from './shared';
@ -135,7 +136,7 @@ export default function dom(
function @add_css () { function @add_css () {
var style = @createElement( 'style' ); var style = @createElement( 'style' );
style.id = '${generator.cssId}-style'; style.id = '${generator.cssId}-style';
style.textContent = ${JSON.stringify(generator.css)}; style.textContent = ${stringify(generator.css)};
@appendNode( style, document.head ); @appendNode( style, document.head );
} }
`); `);
@ -199,9 +200,7 @@ export default function dom(
this._torndown = false; this._torndown = false;
${generator.css && ${generator.css &&
options.css !== false && options.css !== false &&
`if ( !document.getElementById( ${JSON.stringify( `if ( !document.getElementById( '${generator.cssId}-style' ) ) @add_css();`}
generator.cssId + '-style'
)} ) ) @add_css();`}
${(generator.hasComponents || generator.hasIntroTransitions) && ${(generator.hasComponents || generator.hasIntroTransitions) &&
`this._renderHooks = [];`} `this._renderHooks = [];`}
${generator.hasComplexBindings && `this._bindings = [];`} ${generator.hasComplexBindings && `this._bindings = [];`}
@ -280,7 +279,7 @@ export default function dom(
: name; : name;
}); });
result = `import { ${names.join(', ')} } from ${JSON.stringify(sharedPath)};\n\n` + result; result = `import { ${names.join(', ')} } from ${stringify(sharedPath)};\n\n` + result;
} else { } else {
usedHelpers.forEach(key => { usedHelpers.forEach(key => {
const str = shared[key]; const str = shared[key];

@ -2,6 +2,7 @@ import { DomGenerator } from '../../index';
import Block from '../../Block'; import Block from '../../Block';
import { Node } from '../../../../interfaces'; import { Node } from '../../../../interfaces';
import { State } from '../../interfaces'; import { State } from '../../interfaces';
import stringify from '../../../../utils/stringify';
export default function visitAttribute( export default function visitAttribute(
generator: DomGenerator, generator: DomGenerator,
@ -28,7 +29,7 @@ export default function visitAttribute(
if (value.type === 'Text') { if (value.type === 'Text') {
// static attributes // static attributes
const result = isNaN(value.data) const result = isNaN(value.data)
? JSON.stringify(value.data) ? stringify(value.data)
: value.data; : value.data;
local.staticAttributes.push({ local.staticAttributes.push({
name: attribute.name, name: attribute.name,
@ -54,7 +55,7 @@ export default function visitAttribute(
attribute.value attribute.value
.map(chunk => { .map(chunk => {
if (chunk.type === 'Text') { if (chunk.type === 'Text') {
return JSON.stringify(chunk.data); return stringify(chunk.data);
} else { } else {
const { dependencies, snippet } = block.contextualise( const { dependencies, snippet } = block.contextualise(
chunk.expression chunk.expression

@ -15,7 +15,6 @@ export default function visitEachBlock(
const create_each_block = node._block.name; const create_each_block = node._block.name;
const each_block_value = node._block.listName; const each_block_value = node._block.listName;
const iterations = block.getUniqueName(`${each_block}_iterations`); const iterations = block.getUniqueName(`${each_block}_iterations`);
const i = block.alias(`i`);
const params = block.params.join(', '); const params = block.params.join(', ');
const anchor = node.needsAnchor const anchor = node.needsAnchor
? block.getUniqueName(`${each_block}_anchor`) ? block.getUniqueName(`${each_block}_anchor`)
@ -27,7 +26,6 @@ export default function visitEachBlock(
create_each_block, create_each_block,
each_block_value, each_block_value,
iterations, iterations,
i,
params, params,
anchor, anchor,
mountOrIntro, mountOrIntro,
@ -138,7 +136,6 @@ function keyed(
each_block, each_block,
create_each_block, create_each_block,
each_block_value, each_block_value,
i,
params, params,
anchor, anchor,
mountOrIntro, mountOrIntro,
@ -170,15 +167,15 @@ function keyed(
} }
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
for ( var ${i} = 0; ${i} < ${each_block_value}.length; ${i} += 1 ) { for ( var #i = 0; #i < ${each_block_value}.length; #i += 1 ) {
var ${key} = ${each_block_value}[${i}].${node.key}; var ${key} = ${each_block_value}[#i].${node.key};
var ${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i}, ${block.component}, ${key} ); var ${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, ${block.component}, ${key} );
if ( ${last} ) ${last}.next = ${iteration}; if ( ${last} ) ${last}.next = ${iteration};
${iteration}.last = ${last}; ${iteration}.last = ${last};
${last} = ${iteration}; ${last} = ${iteration};
if ( ${i} === 0 ) ${head} = ${iteration}; if ( #i === 0 ) ${head} = ${iteration};
} }
`); `);
@ -231,9 +228,9 @@ function keyed(
${expected} = ${expected}.next; ${expected} = ${expected}.next;
} }
for ( ${i} = 0; ${i} < discard_pile.length; ${i} += 1 ) { for ( #i = 0; #i < discard_pile.length; #i += 1 ) {
if ( discard_pile[${i}].discard ) { if ( discard_pile[#i].discard ) {
${fn}( discard_pile[${i}] ); ${fn}( discard_pile[#i] );
} }
} }
`; `;
@ -253,8 +250,8 @@ function keyed(
${expected} = ${expected}.next; ${expected} = ${expected}.next;
} }
for ( ${i} = 0; ${i} < discard_pile.length; ${i} += 1 ) { for ( #i = 0; #i < discard_pile.length; #i += 1 ) {
var ${iteration} = discard_pile[${i}]; var ${iteration} = discard_pile[#i];
if ( ${iteration}.discard ) { if ( ${iteration}.discard ) {
${fn}( ${iteration} ); ${fn}( ${iteration} );
} }
@ -270,12 +267,12 @@ function keyed(
var discard_pile = []; var discard_pile = [];
for ( ${i} = 0; ${i} < ${each_block_value}.length; ${i} += 1 ) { for ( #i = 0; #i < ${each_block_value}.length; #i += 1 ) {
var ${key} = ${each_block_value}[${i}].${node.key}; var ${key} = ${each_block_value}[#i].${node.key};
var ${iteration} = ${lookup}[${key}]; var ${iteration} = ${lookup}[${key}];
${dynamic && ${dynamic &&
`if ( ${iteration} ) ${iteration}.update( changed, ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i} );`} `if ( ${iteration} ) ${iteration}.update( changed, ${params}, ${each_block_value}, ${each_block_value}[#i], #i );`}
if ( ${expected} ) { if ( ${expected} ) {
if ( ${key} === ${expected}.key ) { if ( ${key} === ${expected}.key ) {
@ -296,7 +293,7 @@ function keyed(
if (!${expected}) ${iteration}.mount( ${parentNode}, ${anchor} ); if (!${expected}) ${iteration}.mount( ${parentNode}, ${anchor} );
} else { } else {
// key is being inserted // key is being inserted
${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i}, ${block.component}, ${key} ); ${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, ${block.component}, ${key} );
${iteration}.create(); ${iteration}.create();
${iteration}.${mountOrIntro}( ${parentNode}, ${expected}.first ); ${iteration}.${mountOrIntro}( ${parentNode}, ${expected}.first );
@ -311,7 +308,7 @@ function keyed(
${iteration}.next = null; ${iteration}.next = null;
${iteration}.mount( ${parentNode}, ${anchor} ); ${iteration}.mount( ${parentNode}, ${anchor} );
} else { } else {
${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i}, ${block.component}, ${key} ); ${iteration} = ${lookup}[${key}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, ${block.component}, ${key} );
${iteration}.create(); ${iteration}.create();
${iteration}.${mountOrIntro}( ${parentNode}, ${anchor} ); ${iteration}.${mountOrIntro}( ${parentNode}, ${anchor} );
} }
@ -360,7 +357,6 @@ function unkeyed(
create_each_block, create_each_block,
each_block_value, each_block_value,
iterations, iterations,
i,
params, params,
anchor, anchor,
mountOrIntro, mountOrIntro,
@ -369,8 +365,8 @@ function unkeyed(
block.builders.init.addBlock(deindent` block.builders.init.addBlock(deindent`
var ${iterations} = []; var ${iterations} = [];
for ( var ${i} = 0; ${i} < ${each_block_value}.length; ${i} += 1 ) { for ( var #i = 0; #i < ${each_block_value}.length; #i += 1 ) {
${iterations}[${i}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i}, ${block.component} ); ${iterations}[#i] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, ${block.component} );
} }
`); `);
@ -378,20 +374,20 @@ function unkeyed(
const anchorNode = state.parentNode ? 'null' : 'anchor'; const anchorNode = state.parentNode ? 'null' : 'anchor';
block.builders.create.addBlock(deindent` block.builders.create.addBlock(deindent`
for ( var ${i} = 0; ${i} < ${iterations}.length; ${i} += 1 ) { for ( var #i = 0; #i < ${iterations}.length; #i += 1 ) {
${iterations}[${i}].create(); ${iterations}[#i].create();
} }
`); `);
block.builders.claim.addBlock(deindent` block.builders.claim.addBlock(deindent`
for ( var ${i} = 0; ${i} < ${iterations}.length; ${i} += 1 ) { for ( var #i = 0; #i < ${iterations}.length; #i += 1 ) {
${iterations}[${i}].claim( ${state.parentNodes} ); ${iterations}[#i].claim( ${state.parentNodes} );
} }
`); `);
block.builders.mount.addBlock(deindent` block.builders.mount.addBlock(deindent`
for ( var ${i} = 0; ${i} < ${iterations}.length; ${i} += 1 ) { for ( var #i = 0; #i < ${iterations}.length; #i += 1 ) {
${iterations}[${i}].${mountOrIntro}( ${targetNode}, ${anchorNode} ); ${iterations}[#i].${mountOrIntro}( ${targetNode}, ${anchorNode} );
} }
`); `);
@ -412,26 +408,26 @@ function unkeyed(
const forLoopBody = node._block.hasUpdateMethod const forLoopBody = node._block.hasUpdateMethod
? node._block.hasIntroMethod ? node._block.hasIntroMethod
? deindent` ? deindent`
if ( ${iterations}[${i}] ) { if ( ${iterations}[#i] ) {
${iterations}[${i}].update( changed, ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i} ); ${iterations}[#i].update( changed, ${params}, ${each_block_value}, ${each_block_value}[#i], #i );
} else { } else {
${iterations}[${i}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i}, ${block.component} ); ${iterations}[#i] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, ${block.component} );
${iterations}[${i}].create(); ${iterations}[#i].create();
} }
${iterations}[${i}].intro( ${parentNode}, ${anchor} ); ${iterations}[#i].intro( ${parentNode}, ${anchor} );
` `
: deindent` : deindent`
if ( ${iterations}[${i}] ) { if ( ${iterations}[#i] ) {
${iterations}[${i}].update( changed, ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i} ); ${iterations}[#i].update( changed, ${params}, ${each_block_value}, ${each_block_value}[#i], #i );
} else { } else {
${iterations}[${i}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i}, ${block.component} ); ${iterations}[#i] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, ${block.component} );
${iterations}[${i}].create(); ${iterations}[#i].create();
${iterations}[${i}].mount( ${parentNode}, ${anchor} ); ${iterations}[#i].mount( ${parentNode}, ${anchor} );
} }
` `
: deindent` : deindent`
${iterations}[${i}] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[${i}], ${i}, ${block.component} ); ${iterations}[#i] = ${create_each_block}( ${params}, ${each_block_value}, ${each_block_value}[#i], #i, ${block.component} );
${iterations}[${i}].${mountOrIntro}( ${parentNode}, ${anchor} ); ${iterations}[#i].${mountOrIntro}( ${parentNode}, ${anchor} );
`; `;
const start = node._block.hasUpdateMethod ? '0' : `${iterations}.length`; const start = node._block.hasUpdateMethod ? '0' : `${iterations}.length`;
@ -449,12 +445,12 @@ function unkeyed(
} }
} }
for ( ; ${i} < ${iterations}.length; ${i} += 1 ) ${outro}( ${i} ); for ( ; #i < ${iterations}.length; #i += 1 ) ${outro}( #i );
` `
: deindent` : deindent`
for ( ; ${i} < ${iterations}.length; ${i} += 1 ) { for ( ; #i < ${iterations}.length; #i += 1 ) {
${iterations}[${i}].unmount(); ${iterations}[#i].unmount();
${iterations}[${i}].destroy(); ${iterations}[#i].destroy();
} }
${iterations}.length = ${each_block_value}.length; ${iterations}.length = ${each_block_value}.length;
`; `;
@ -463,7 +459,7 @@ function unkeyed(
var ${each_block_value} = ${snippet}; var ${each_block_value} = ${snippet};
if ( ${condition} ) { if ( ${condition} ) {
for ( var ${i} = ${start}; ${i} < ${each_block_value}.length; ${i} += 1 ) { for ( var #i = ${start}; #i < ${each_block_value}.length; #i += 1 ) {
${forLoopBody} ${forLoopBody}
} }
@ -473,8 +469,8 @@ function unkeyed(
} }
block.builders.unmount.addBlock(deindent` block.builders.unmount.addBlock(deindent`
for ( var ${i} = 0; ${i} < ${iterations}.length; ${i} += 1 ) { for ( var #i = 0; #i < ${iterations}.length; #i += 1 ) {
${iterations}[${i}].unmount(); ${iterations}[#i].unmount();
} }
`); `);

@ -1,5 +1,6 @@
import attributeLookup from './lookup'; import attributeLookup from './lookup';
import deindent from '../../../../utils/deindent'; import deindent from '../../../../utils/deindent';
import stringify from '../../../../utils/stringify';
import getStaticAttributeValue from './getStaticAttributeValue'; import getStaticAttributeValue from './getStaticAttributeValue';
import { DomGenerator } from '../../index'; import { DomGenerator } from '../../index';
import Block from '../../Block'; import Block from '../../Block';
@ -57,7 +58,7 @@ export default function visitAttribute(
attribute.value attribute.value
.map((chunk: Node) => { .map((chunk: Node) => {
if (chunk.type === 'Text') { if (chunk.type === 'Text') {
return JSON.stringify(chunk.data); return stringify(chunk.data);
} else { } else {
const { snippet } = block.contextualise(chunk.expression); const { snippet } = block.contextualise(chunk.expression);
return `( ${snippet} )`; return `( ${snippet} )`;
@ -127,7 +128,7 @@ export default function visitAttribute(
? 'true' ? 'true'
: attribute.value.length === 0 : attribute.value.length === 0
? `''` ? `''`
: JSON.stringify(attribute.value[0].data); : stringify(attribute.value[0].data);
const statement = propertyName const statement = propertyName
? `${state.parentNode}.${propertyName} = ${value};` ? `${state.parentNode}.${propertyName} = ${value};`

@ -57,7 +57,7 @@ export default function visitBinding(
value, value,
}); });
let updateElement = `${state.parentNode}.${attribute.name} = ${snippet};`; let updateElement = `${state.parentNode}.${attribute.name} = ${snippet};`;
const lock = block.alias(`${state.parentNode}_updating`); const lock = `#${state.parentNode}_updating`;
let updateCondition = `!${lock}`; let updateCondition = `!${lock}`;
block.addVariable(lock, 'false'); block.addVariable(lock, 'false');
@ -69,7 +69,6 @@ export default function visitBinding(
} }
const value = block.getUniqueName('value'); const value = block.getUniqueName('value');
const i = block.alias('i');
const option = block.getUniqueName('option'); const option = block.getUniqueName('option');
const ifStatement = isMultipleSelect const ifStatement = isMultipleSelect
@ -83,8 +82,8 @@ export default function visitBinding(
updateElement = deindent` updateElement = deindent`
var ${value} = ${snippet}; var ${value} = ${snippet};
for ( var ${i} = 0; ${i} < ${state.parentNode}.options.length; ${i} += 1 ) { for ( var #i = 0; #i < ${state.parentNode}.options.length; #i += 1 ) {
var ${option} = ${state.parentNode}.options[${i}]; var ${option} = ${state.parentNode}.options[#i];
${ifStatement} ${ifStatement}
} }

@ -34,7 +34,7 @@ export default function addTransitions(
block.builders.outro.addBlock(deindent` block.builders.outro.addBlock(deindent`
${name}.run( false, function () { ${name}.run( false, function () {
${block.component}.fire( 'outro.end', { node: ${state.name} }); ${block.component}.fire( 'outro.end', { node: ${state.name} });
if ( --${block.alias('outros')} === 0 ) ${block.alias('outrocallback')}(); if ( --#outros === 0 ) #outrocallback();
${name} = null; ${name} = null;
}); });
`); `);
@ -81,7 +81,7 @@ export default function addTransitions(
${outroName} = @wrapTransition( ${state.name}, ${fn}, ${snippet}, false, null ); ${outroName} = @wrapTransition( ${state.name}, ${fn}, ${snippet}, false, null );
${outroName}.run( false, function () { ${outroName}.run( false, function () {
${block.component}.fire( 'outro.end', { node: ${state.name} }); ${block.component}.fire( 'outro.end', { node: ${state.name} });
if ( --${block.alias('outros')} === 0 ) ${block.alias('outrocallback')}(); if ( --#outros === 0 ) #outrocallback();
}); });
`); `);
} }

@ -2,6 +2,7 @@ import { DomGenerator } from '../index';
import Block from '../Block'; import Block from '../Block';
import { Node } from '../../../interfaces'; import { Node } from '../../../interfaces';
import { State } from '../interfaces'; import { State } from '../interfaces';
import stringify from '../../../utils/stringify';
export default function visitText( export default function visitText(
generator: DomGenerator, generator: DomGenerator,
@ -12,8 +13,8 @@ export default function visitText(
if (!node._state.shouldCreate) return; if (!node._state.shouldCreate) return;
block.addElement( block.addElement(
node._state.name, node._state.name,
`@createText( ${JSON.stringify(node.data)} )`, `@createText( ${stringify(node.data)} )`,
generator.hydratable ? `@claimText( ${state.parentNodes}, ${JSON.stringify(node.data)} )` : '', generator.hydratable ? `@claimText( ${state.parentNodes}, ${stringify(node.data)} )` : '',
state.parentNode, state.parentNode,
node.usedAsAnchor node.usedAsAnchor
); );

@ -33,8 +33,6 @@ export default function getSetter({
} }
if (attribute.value.type === 'MemberExpression') { if (attribute.value.type === 'MemberExpression') {
const alias = block.alias(name);
return deindent` return deindent`
var state = ${block.component}.get(); var state = ${block.component}.get();
${snippet} = ${value}; ${snippet} = ${value};

@ -2,6 +2,7 @@ import deindent from '../../utils/deindent';
import Generator from '../Generator'; import Generator from '../Generator';
import Block from './Block'; import Block from './Block';
import visit from './visit'; import visit from './visit';
import stringify from '../../utils/stringify';
import { Parsed, Node, CompileOptions } from '../../interfaces'; import { Parsed, Node, CompileOptions } from '../../interfaces';
export class SsrGenerator extends Generator { export class SsrGenerator extends Generator {
@ -55,7 +56,7 @@ export default function ssr(
var ${name} = {}; var ${name} = {};
${name}.filename = ${JSON.stringify(options.filename)}; ${name}.filename = ${stringify(options.filename)};
${name}.data = function () { ${name}.data = function () {
return ${templateProperties.data return ${templateProperties.data
@ -95,7 +96,7 @@ export default function ssr(
deindent` deindent`
components.push({ components.push({
filename: ${name}.filename, filename: ${name}.filename,
css: ${JSON.stringify(generator.css)}, css: ${stringify(generator.css)},
map: null // TODO map: null // TODO
}); });
`} `}

@ -4,6 +4,7 @@ import { SsrGenerator } from '../index';
import Block from '../Block'; import Block from '../Block';
import { Node } from '../../../interfaces'; import { Node } from '../../../interfaces';
import getObject from '../../../utils/getObject'; import getObject from '../../../utils/getObject';
import stringify from '../../../utils/stringify';
import getTailSnippet from '../../../utils/getTailSnippet'; import getTailSnippet from '../../../utils/getTailSnippet';
export default function visitComponent( export default function visitComponent(
@ -11,7 +12,7 @@ export default function visitComponent(
block: Block, block: Block,
node: Node node: Node
) { ) {
function stringify(chunk: Node) { function stringifyAttribute(chunk: Node) {
if (chunk.type === 'Text') return chunk.data; if (chunk.type === 'Text') return chunk.data;
if (chunk.type === 'MustacheTag') { if (chunk.type === 'MustacheTag') {
const { snippet } = block.contextualise(chunk.expression); const { snippet } = block.contextualise(chunk.expression);
@ -41,13 +42,13 @@ export default function visitComponent(
} else if (attribute.value.length === 1) { } else if (attribute.value.length === 1) {
const chunk = attribute.value[0]; const chunk = attribute.value[0];
if (chunk.type === 'Text') { if (chunk.type === 'Text') {
value = isNaN(chunk.data) ? JSON.stringify(chunk.data) : chunk.data; value = isNaN(chunk.data) ? stringify(chunk.data) : chunk.data;
} else { } else {
const { snippet } = block.contextualise(chunk.expression); const { snippet } = block.contextualise(chunk.expression);
value = snippet; value = snippet;
} }
} else { } else {
value = '`' + attribute.value.map(stringify).join('') + '`'; value = '`' + attribute.value.map(stringifyAttribute).join('') + '`';
} }
return `${attribute.name}: ${value}`; return `${attribute.name}: ${value}`;

@ -0,0 +1,3 @@
export default function stringify(data: string) {
return JSON.stringify(data.replace(/([^\\])?([@#])/g, '$1\\$2'));
}

@ -198,7 +198,7 @@ function SvelteComponent ( options ) {
this._yield = options._yield; this._yield = options._yield;
this._torndown = false; this._torndown = false;
if ( !document.getElementById( "svelte-3842350206-style" ) ) add_css(); if ( !document.getElementById( 'svelte-3842350206-style' ) ) add_css();
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment( this._state, this );

@ -63,7 +63,7 @@ function SvelteComponent ( options ) {
this._yield = options._yield; this._yield = options._yield;
this._torndown = false; this._torndown = false;
if ( !document.getElementById( "svelte-3842350206-style" ) ) add_css(); if ( !document.getElementById( 'svelte-3842350206-style' ) ) add_css();
this._fragment = create_main_fragment( this._state, this ); this._fragment = create_main_fragment( this._state, this );

@ -65,11 +65,16 @@ describe("ssr", () => {
fs.writeFileSync(`${dir}/_actual.html`, html); fs.writeFileSync(`${dir}/_actual.html`, html);
if (css) fs.writeFileSync(`${dir}/_actual.css`, css); if (css) fs.writeFileSync(`${dir}/_actual.css`, css);
try {
assert.htmlEqual(html, expectedHtml); assert.htmlEqual(html, expectedHtml);
assert.equal( assert.equal(
css.replace(/^\s+/gm, ""), css.replace(/^\s+/gm, ""),
expectedCss.replace(/^\s+/gm, "") expectedCss.replace(/^\s+/gm, "")
); );
} catch (err) {
showOutput(dir, { generate: 'ssr' });
throw err;
}
}); });
}); });

Loading…
Cancel
Save