Merge branch 'master' into gh-312

pull/386/head
Rich Harris 8 years ago
commit db36e90259

@ -46,6 +46,8 @@ export default class Generator {
}
contextualise ( expression, isEventHandler ) {
this.addSourcemapLocations( expression );
const usedContexts = [];
const dependencies = [];

@ -4,7 +4,6 @@ export default {
enter ( generator, node ) {
const name = generator.current.getUniqueName( 'text' );
generator.addSourcemapLocations( node.expression );
const { snippet } = generator.contextualise( node.expression );
generator.current.builders.init.addLine( `var last_${name} = ${snippet}` );

@ -4,7 +4,6 @@ export default {
enter ( generator, node ) {
const name = generator.current.getUniqueName( 'raw' );
generator.addSourcemapLocations( node.expression );
const { snippet } = generator.contextualise( node.expression );
// we would have used comments here, but the `insertAdjacentHTML` api only

@ -57,8 +57,6 @@ export default function addComponentAttributes ( generator, node, local ) {
if ( chunk.type === 'Text' ) {
return JSON.stringify( chunk.data );
} else {
generator.addSourcemapLocations( chunk.expression );
const { dependencies, string } = generator.contextualise( chunk.expression );
dependencies.forEach( dependency => {
if ( !~allDependencies.indexOf( dependency ) ) allDependencies.push( dependency );
@ -84,7 +82,7 @@ export default function addComponentAttributes ( generator, node, local ) {
const usedContexts = [];
attribute.expression.arguments.forEach( arg => {
const { contexts } = generator.contextualise( arg, true, true );
const { contexts } = generator.contextualise( arg, true );
contexts.forEach( context => {
if ( !~usedContexts.indexOf( context ) ) usedContexts.push( context );

@ -96,7 +96,7 @@ export default function addElementAttributes ( generator, node, local ) {
if ( propertyName ) {
updater = `${local.name}.${propertyName} = ${last};`;
} else {
updater = `${generator.helper( method )}( ${local.name}, '${name}', ${last} );`; // TODO use snippet both times see note below
updater = `${generator.helper( method )}( ${local.name}, '${name}', ${last} );`;
}
local.init.addLine( updater );
@ -117,10 +117,8 @@ export default function addElementAttributes ( generator, node, local ) {
if ( chunk.type === 'Text' ) {
return JSON.stringify( chunk.data );
} else {
generator.addSourcemapLocations( chunk.expression );
const { string } = generator.contextualise( chunk.expression ); // TODO use snippet for sourcemap support need to add a 'copy' feature to MagicString first
return `( ${string} )`;
const { snippet } = generator.contextualise( chunk.expression );
return `( ${snippet} )`;
}
}).join( ' + ' )
);

Loading…
Cancel
Save