Merge branch 'master' into gh-1948

pull/1965/head
Richard Harris 6 years ago
commit c0a218b69e

27
package-lock.json generated

@ -1,6 +1,6 @@
{ {
"name": "svelte", "name": "svelte",
"version": "3.0.0-alpha13", "version": "3.0.0-alpha16",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -217,19 +217,16 @@
"dev": true "dev": true
}, },
"acorn": { "acorn": {
"version": "5.7.3", "version": "6.0.5",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.5.tgz",
"integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", "integrity": "sha512-i33Zgp3XWtmZBMNvCr4azvOFeWVw1Rk6p3hfi3LUDvIFraOMywb1kAtrbi+med14m4Xfpqm3zRZMT+c0FNE7kg==",
"dev": true "dev": true
}, },
"acorn-dynamic-import": { "acorn-dynamic-import": {
"version": "3.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz", "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-4.0.0.tgz",
"integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==", "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==",
"dev": true, "dev": true
"requires": {
"acorn": "^5.0.0"
}
}, },
"acorn-globals": { "acorn-globals": {
"version": "4.3.0", "version": "4.3.0",
@ -2934,6 +2931,14 @@
"whatwg-url": "^6.4.1", "whatwg-url": "^6.4.1",
"ws": "^5.2.0", "ws": "^5.2.0",
"xml-name-validator": "^3.0.0" "xml-name-validator": "^3.0.0"
},
"dependencies": {
"acorn": {
"version": "5.7.3",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz",
"integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==",
"dev": true
}
} }
}, },
"jsesc": { "jsesc": {

@ -1,6 +1,6 @@
{ {
"name": "svelte", "name": "svelte",
"version": "3.0.0-alpha15", "version": "3.0.0-alpha16",
"description": "The magical disappearing UI framework", "description": "The magical disappearing UI framework",
"module": "index.mjs", "module": "index.mjs",
"main": "index.js", "main": "index.js",
@ -55,8 +55,8 @@
"devDependencies": { "devDependencies": {
"@types/mocha": "^5.2.0", "@types/mocha": "^5.2.0",
"@types/node": "^10.5.5", "@types/node": "^10.5.5",
"acorn": "^5.4.1", "acorn": "^6.0.5",
"acorn-dynamic-import": "^3.0.0", "acorn-dynamic-import": "^4.0.0",
"agadoo": "^1.0.1", "agadoo": "^1.0.1",
"codecov": "^3.0.0", "codecov": "^3.0.0",
"css-tree": "1.0.0-alpha22", "css-tree": "1.0.0-alpha22",

@ -170,6 +170,7 @@ export default class Component {
const props = [...this.template_references]; const props = [...this.template_references];
this.declarations.push(...props); this.declarations.push(...props);
addToSet(this.writable_declarations, this.template_references); addToSet(this.writable_declarations, this.template_references);
addToSet(this.userVars, this.template_references);
this.props = props.map(name => ({ this.props = props.map(name => ({
name, name,

@ -114,7 +114,7 @@ export default class WindowWrapper extends Wrapper {
}); });
block.event_listeners.push(deindent` block.event_listeners.push(deindent`
@addListener(window, "${event}", ctx.${handler_name}); @addListener(window, "${event}", ctx.${handler_name})
`); `);
} }
@ -179,4 +179,4 @@ export default class WindowWrapper extends Wrapper {
`); `);
} }
} }
} }

@ -0,0 +1,15 @@
import * as acorn from 'acorn';
import dynamicImport from 'acorn-dynamic-import';
const Parser = acorn.Parser.extend(dynamicImport);
export const parse = (source: string, options: any) => Parser.parse(source, {
sourceType: 'module',
ecmaVersion: 9,
preserveParens: true
});
export const parseExpressionAt = (source: string, index: number, options: any) => Parser.parseExpressionAt(source, index, {
ecmaVersion: 9,
preserveParens: true
});

@ -1,4 +1,4 @@
import { parseExpressionAt } from 'acorn'; import { parseExpressionAt } from '../acorn';
import { Parser } from '../index'; import { Parser } from '../index';
const literals = new Map([['true', true], ['false', false], ['null', null]]); const literals = new Map([['true', true], ['false', false], ['null', null]]);
@ -31,13 +31,7 @@ export default function readExpression(parser: Parser) {
parser.index = start; parser.index = start;
try { try {
const node = parseExpressionAt(parser.template, parser.index, { const node = parseExpressionAt(parser.template, parser.index);
ecmaVersion: 9,
preserveParens: true,
plugins: {
dynamicImport: true
}
});
parser.index = node.end; parser.index = node.end;
return node; return node;

@ -1,13 +1,10 @@
import * as acorn from 'acorn'; import * as acorn from '../acorn';
import injectDynamicImport from 'acorn-dynamic-import/src/inject';
import repeat from '../../utils/repeat'; import repeat from '../../utils/repeat';
import { Parser } from '../index'; import { Parser } from '../index';
import { Node } from '../../interfaces'; import { Node } from '../../interfaces';
const scriptClosingTag = '</script>'; const scriptClosingTag = '</script>';
injectDynamicImport(acorn);
export default function readScript(parser: Parser, start: number, attributes: Node[]) { export default function readScript(parser: Parser, start: number, attributes: Node[]) {
const scriptStart = parser.index; const scriptStart = parser.index;
const scriptEnd = parser.template.indexOf(scriptClosingTag, scriptStart); const scriptEnd = parser.template.indexOf(scriptClosingTag, scriptStart);
@ -24,13 +21,7 @@ export default function readScript(parser: Parser, start: number, attributes: No
let ast; let ast;
try { try {
ast = acorn.parse(source, { ast = acorn.parse(source);
ecmaVersion: 9,
sourceType: 'module',
plugins: {
dynamicImport: true
}
});
} catch (err) { } catch (err) {
parser.acornError(err); parser.acornError(err);
} }

@ -395,7 +395,7 @@ function readAttribute(parser: Parser, uniqueNames: Set<string>) {
parser.allowWhitespace(); parser.allowWhitespace();
const colon_index = name.indexOf(':'); const colon_index = name.indexOf(':');
const type = colon_index !== 1 && get_directive_type(name.slice(0, colon_index)); const type = colon_index !== -1 && get_directive_type(name.slice(0, colon_index));
let value: any[] | true = true; let value: any[] | true = true;
if (parser.eat('=')) { if (parser.eat('=')) {

@ -1,5 +1,5 @@
/* generated by Svelte vX.Y.Z */ /* generated by Svelte vX.Y.Z */
import { SvelteComponent as SvelteComponent_1, append, createComment, createElement, createText, destroyEach, detachNode, flush, init, insert, run, safe_not_equal, setData } from "svelte/internal"; import { SvelteComponent as SvelteComponent_1, append, createComment, createElement as createElement_1, createText, destroyEach, detachNode, flush, init, insert, run, safe_not_equal, setData } from "svelte/internal";
function get_each_context(ctx, list, i) { function get_each_context(ctx, list, i) {
const child_ctx = Object.create(ctx); const child_ctx = Object.create(ctx);
@ -13,7 +13,7 @@ function create_each_block($$, ctx) {
return { return {
c() { c() {
span = createElement("span"); span = createElement_1("span");
text = createText(text_value); text = createText(text_value);
}, },

@ -2,7 +2,7 @@
import { SvelteComponent as SvelteComponent_1, append, createElement, detachNode, flush, init, insert, run, safe_not_equal } from "svelte/internal"; import { SvelteComponent as SvelteComponent_1, append, createElement, detachNode, flush, init, insert, run, safe_not_equal } from "svelte/internal";
function create_fragment($$, ctx) { function create_fragment($$, ctx) {
var select, option0, option1, select_value_value, current; var select, option0, option1, select_value_value, current_1;
return { return {
c() { c() {
@ -32,7 +32,7 @@ function create_fragment($$, ctx) {
} }
} }
current = true; current_1 = true;
}, },
p(changed, ctx) { p(changed, ctx) {
@ -49,7 +49,7 @@ function create_fragment($$, ctx) {
}, },
i(target, anchor) { i(target, anchor) {
if (current) return; if (current_1) return;
this.m(target, anchor); this.m(target, anchor);
}, },

@ -0,0 +1,11 @@
export default {
preserveIdentifiers: true,
props: {
click_handler: 'x'
},
html: `
<button>x</button>
`
};

@ -0,0 +1 @@
<button on:click="{() => foo()}">{click_handler}</button>

@ -0,0 +1,9 @@
export default {
props: {
currentUser: { name: 'world' }
},
html: `
<h1>Hello world!</h1>
`
};

@ -0,0 +1,6 @@
<script>
import Nested from './Nested.html';
export let currentUser;
</script>
<Nested user={currentUser}/>

@ -0,0 +1,3 @@
export default {
html: '<button>Click</button>'
};

@ -0,0 +1,2 @@
<svelte:window bind:innerWidth={width} bind:innerHeight={height}/>
<button on:click={() => {}}>Click</button>
Loading…
Cancel
Save