Merge pull request #4 from sveltejs/master

Sync Fork from Upstream Repo
pull/3941/head
Stefan Hagen 6 years ago committed by GitHub
commit 6042d7582a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

6
package-lock.json generated

@ -500,9 +500,9 @@
"dev": true "dev": true
}, },
"code-red": { "code-red": {
"version": "0.0.18", "version": "0.0.19",
"resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.18.tgz", "resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.19.tgz",
"integrity": "sha512-g7W6RwRqBbQTtMaUqrNWDyyl2GK0Uulk/uZPzGdgTXpOGX/LA8bW67EKQLdQgpYfd6APhZVwoX2lrL7mnJOWkA==", "integrity": "sha512-pzkA9ikMLR7KatByUJVz33kQKkrDnsJhyuvxSSUnyJNBggkGNStmDe/ezYvfP4CZ9XM7vYIID+YIaMJnlYGzLg==",
"dev": true, "dev": true,
"requires": { "requires": {
"acorn": "^7.1.0", "acorn": "^7.1.0",

@ -56,15 +56,15 @@
}, },
"homepage": "https://github.com/sveltejs/svelte#README", "homepage": "https://github.com/sveltejs/svelte#README",
"devDependencies": { "devDependencies": {
"@rollup/plugin-replace": "^2.2.1",
"@types/mocha": "^5.2.7", "@types/mocha": "^5.2.7",
"@types/node": "^8.10.53", "@types/node": "^8.10.53",
"@typescript-eslint/eslint-plugin": "^1.13.0", "@typescript-eslint/eslint-plugin": "^1.13.0",
"@typescript-eslint/parser": "^2.1.0", "@typescript-eslint/parser": "^2.1.0",
"@rollup/plugin-replace": "^2.2.1",
"acorn": "^7.1.0", "acorn": "^7.1.0",
"agadoo": "^1.1.0", "agadoo": "^1.1.0",
"c8": "^5.0.1", "c8": "^5.0.1",
"code-red": "0.0.18", "code-red": "0.0.19",
"codecov": "^3.5.0", "codecov": "^3.5.0",
"css-tree": "1.0.0-alpha22", "css-tree": "1.0.0-alpha22",
"eslint": "^6.3.0", "eslint": "^6.3.0",

@ -6,7 +6,9 @@ authorURL: https://twitter.com/Rich_Harris
draft: true draft: true
--- ---
*Coming soon* This post will walk you through setting up your editor so that recognises Svelte files: *__Coming soon__*
This post will walk you through setting up your editor so that recognises Svelte files:
* eslint-plugin-svelte3 * eslint-plugin-svelte3
* svelte-vscode * svelte-vscode
@ -14,7 +16,7 @@ draft: true
## Atom ## Atom
To treat `*.svelte` files as HTML, open Edit → Config... and add the following lines to your `core` section: To treat `*.svelte` files as HTML, open *__Edit → Config...__* and add the following lines to your `core` section:
```cson ```cson
"*": "*":
@ -45,3 +47,23 @@ To set the filetype for a single file, use a [modeline](https://vim.fandom.com/w
``` ```
<!-- vim: set ft=html :--> <!-- vim: set ft=html :-->
``` ```
## Visual Studio Code
To treat `*.svelte` files as HTML, add the following lines to your `settings.json` file:
```cson
"files.associations": {
"*.svelte": "html"
}
```
## JetBrains WebStorm
To treat `*.svelte` files as HTML in WebStorm, you need to create a new file type association. Please refer to the [JetBrains website](https://www.jetbrains.com/help/webstorm/creating-and-registering-file-types.html) to see how.
## Sublime Text 3
Open any `.svelte` file.
Go to *__View → Syntax → Open all with current extension as... → HTML__*.

@ -1146,7 +1146,7 @@ bind:property={variable}
--- ---
You can bind to component props using the same mechanism. You can bind to component props using the same syntax as for elements.
```html ```html
<Keypad bind:value={pin}/> <Keypad bind:value={pin}/>

@ -33,7 +33,7 @@
font-family: 'Overpass'; font-family: 'Overpass';
letter-spacing: 0.12em; letter-spacing: 0.12em;
color: #676778; color: #676778;
font-weight: 100; font-weight: 400;
} }
.centered span { .centered span {
@ -71,4 +71,4 @@
toggle me toggle me
</label> </label>
<link href="https://fonts.googleapis.com/css?family=Overpass:100" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Overpass:100,400" rel="stylesheet">

@ -30,3 +30,12 @@ function addNumber() {
numbers[numbers.length] = numbers.length + 1; numbers[numbers.length] = numbers.length + 1;
} }
``` ```
A simple rule of thumb: the name of the updated variable must appear on the left hand side of the assignment. For example this...
```js
const foo = obj.foo;
foo.bar = 'baz';
```
...won't update references to `obj.foo.bar`, unless you follow it up with `obj = obj`.

@ -28,7 +28,7 @@ Clicking the buttons causes the progress bar to animate to its new value. It's a
</script> </script>
``` ```
> The `svelte/easing` module contains the [Penner easing equations](http://robertpenner.com/easing/), or you can supply your own `p => t` function where `p` and `t` are both values between 0 and 1. > The `svelte/easing` module contains the [Penner easing equations](https://web.archive.org/web/20190805215728/http://robertpenner.com/easing/), or you can supply your own `p => t` function where `p` and `t` are both values between 0 and 1.
The full set of options available to `tweened`: The full set of options available to `tweened`:
@ -37,4 +37,4 @@ The full set of options available to `tweened`:
* `easing` — a `p => t` function * `easing` — a `p => t` function
* `interpolate` — a custom `(from, to) => t => value` function for interpolating between arbitrary values. By default, Svelte will interpolate between numbers, dates, and identically-shaped arrays and objects (as long as they only contain numbers and dates or other valid arrays and objects). If you want to interpolate (for example) colour strings or transformation matrices, supply a custom interpolator * `interpolate` — a custom `(from, to) => t => value` function for interpolating between arbitrary values. By default, Svelte will interpolate between numbers, dates, and identically-shaped arrays and objects (as long as they only contain numbers and dates or other valid arrays and objects). If you want to interpolate (for example) colour strings or transformation matrices, supply a custom interpolator
You can also pass these options to `progress.set` and `progress.update` as a second argument, in which case they will override the defaults. The `set` and `update` methods both return a promise that resolves when the tween completes. You can also pass these options to `progress.set` and `progress.update` as a second argument, in which case they will override the defaults. The `set` and `update` methods both return a promise that resolves when the tween completes.

@ -240,8 +240,7 @@ export default class Component {
const { compile_options, name } = this; const { compile_options, name } = this;
const { format = 'esm' } = compile_options; const { format = 'esm' } = compile_options;
// TODO reinstate banner (along with fragment marker comments) const banner = `${this.file ? `${this.file} ` : ``}generated by Svelte v${'__VERSION__'}`;
const banner = `/* ${this.file ? `${this.file} ` : ``}generated by Svelte v${'__VERSION__'} */`;
const program: any = { type: 'Program', body: result }; const program: any = { type: 'Program', body: result };

@ -44,7 +44,7 @@ function edit_source(source, sveltePath) {
function esm( function esm(
program: any, program: any,
name: Identifier, name: Identifier,
_banner: string, banner: string,
sveltePath: string, sveltePath: string,
internal_path: string, internal_path: string,
helpers: Array<{ name: string; alias: Identifier }>, helpers: Array<{ name: string; alias: Identifier }>,
@ -98,6 +98,8 @@ function esm(
}; };
program.body = b` program.body = b`
/* ${banner} */
${import_declaration} ${import_declaration}
${internal_globals} ${internal_globals}
${imports} ${imports}
@ -112,7 +114,7 @@ function esm(
function cjs( function cjs(
program: any, program: any,
name: Identifier, name: Identifier,
_banner: string, banner: string,
sveltePath: string, sveltePath: string,
internal_path: string, internal_path: string,
helpers: Array<{ name: string; alias: Identifier }>, helpers: Array<{ name: string; alias: Identifier }>,
@ -188,6 +190,8 @@ function cjs(
const exports = module_exports.map(x => b`exports.${{ type: 'Identifier', name: x.as }} = ${{ type: 'Identifier', name: x.name }};`); const exports = module_exports.map(x => b`exports.${{ type: 'Identifier', name: x.as }} = ${{ type: 'Identifier', name: x.name }};`);
program.body = b` program.body = b`
/* ${banner} */
"use strict"; "use strict";
${internal_requires} ${internal_requires}
${internal_globals} ${internal_globals}

@ -423,17 +423,17 @@ export default class Block {
const key = this.key && this.get_unique_name('key'); const key = this.key && this.get_unique_name('key');
const args: any[] = [x`#ctx`]; const args: any[] = [x`#ctx`];
if (key) args.unshift(key); if (key) args.unshift(key);
// TODO include this.comment const fn = b`function ${this.name}(${args}) {
// ${this.comment && `// ${escape(this.comment, { only_escape_at_symbol: true })}`} ${this.get_contents(key)}
}`;
return b` return this.comment
function ${this.name}(${args}) { ? b`
${this.get_contents(key)} // ${this.comment}
} ${fn}`
`; : fn;
} }
render_listeners(chunk: string = '') { render_listeners(chunk: string = '') {

@ -7,7 +7,6 @@ import { b, x } from 'code-red';
import Expression from '../../../nodes/shared/Expression'; import Expression from '../../../nodes/shared/Expression';
import Text from '../../../nodes/Text'; import Text from '../../../nodes/Text';
import { changed } from '../shared/changed'; import { changed } from '../shared/changed';
import { Literal } from 'estree';
export default class AttributeWrapper { export default class AttributeWrapper {
node: Attribute; node: Attribute;
@ -72,89 +71,81 @@ export default class AttributeWrapper {
const is_legacy_input_type = element.renderer.component.compile_options.legacy && name === 'type' && this.parent.node.name === 'input'; const is_legacy_input_type = element.renderer.component.compile_options.legacy && name === 'type' && this.parent.node.name === 'input';
const dependencies = this.node.get_dependencies(); const dependencies = this.node.get_dependencies();
if (dependencies.length > 0) { const value = this.get_value(block);
let value;
// TODO some of this code is repeated in Tag.ts — would be good to
// DRY it out if that's possible without introducing crazy indirection
if (this.node.chunks.length === 1) {
// single {tag} — may be a non-string
value = (this.node.chunks[0] as Expression).manipulate(block);
} else {
value = this.node.name === 'class'
? this.get_class_name_text()
: this.render_chunks().reduce((lhs, rhs) => x`${lhs} + ${rhs}`);
// '{foo} {bar}' — treat as string concatenation
if (this.node.chunks[0].type !== 'Text') {
value = x`"" + ${value}`;
}
}
const is_select_value_attribute = const is_src = this.node.name === 'src'; // TODO retire this exception in favour of https://github.com/sveltejs/svelte/issues/3750
name === 'value' && element.node.name === 'select'; const is_select_value_attribute =
name === 'value' && element.node.name === 'select';
const should_cache = is_select_value_attribute; // TODO is this necessary? const should_cache = is_src || this.node.should_cache() || is_select_value_attribute; // TODO is this necessary?
const last = should_cache && block.get_unique_name( const last = should_cache && block.get_unique_name(
`${element.var.name}_${name.replace(/[^a-zA-Z_$]/g, '_')}_value` `${element.var.name}_${name.replace(/[^a-zA-Z_$]/g, '_')}_value`
); );
if (should_cache) block.add_variable(last); if (should_cache) block.add_variable(last);
let updater; let updater;
const init = should_cache ? x`${last} = ${value}` : value; const init = should_cache ? x`${last} = ${value}` : value;
if (is_legacy_input_type) { if (is_legacy_input_type) {
block.chunks.hydrate.push( block.chunks.hydrate.push(
b`@set_input_type(${element.var}, ${init});` b`@set_input_type(${element.var}, ${init});`
); );
updater = b`@set_input_type(${element.var}, ${should_cache ? last : value});`; updater = b`@set_input_type(${element.var}, ${should_cache ? last : value});`;
} else if (is_select_value_attribute) { } else if (is_select_value_attribute) {
// annoying special case // annoying special case
const is_multiple_select = element.node.get_static_attribute_value('multiple'); const is_multiple_select = element.node.get_static_attribute_value('multiple');
const i = block.get_unique_name('i'); const i = block.get_unique_name('i');
const option = block.get_unique_name('option'); const option = block.get_unique_name('option');
const if_statement = is_multiple_select const if_statement = is_multiple_select
? b` ? b`
${option}.selected = ~${last}.indexOf(${option}.__value);` ${option}.selected = ~${last}.indexOf(${option}.__value);`
: b` : b`
if (${option}.__value === ${last}) { if (${option}.__value === ${last}) {
${option}.selected = true; ${option}.selected = true;
${{ type: 'BreakStatement' }}; ${{ type: 'BreakStatement' }};
}`; // TODO the BreakStatement is gross, but it's unsyntactic otherwise... }`; // TODO the BreakStatement is gross, but it's unsyntactic otherwise...
updater = b` updater = b`
for (var ${i} = 0; ${i} < ${element.var}.options.length; ${i} += 1) { for (var ${i} = 0; ${i} < ${element.var}.options.length; ${i} += 1) {
var ${option} = ${element.var}.options[${i}]; var ${option} = ${element.var}.options[${i}];
${if_statement} ${if_statement}
} }
`; `;
block.chunks.mount.push(b` block.chunks.mount.push(b`
${last} = ${value}; ${last} = ${value};
${updater} ${updater}
`); `);
} else if (property_name) { } else if (is_src) {
block.chunks.hydrate.push( block.chunks.hydrate.push(
b`${element.var}.${property_name} = ${init};` b`if (${element.var}.src !== ${init}) ${method}(${element.var}, "${name}", ${last});`
); );
updater = block.renderer.options.dev updater = b`${method}(${element.var}, "${name}", ${should_cache ? last : value});`;
? b`@prop_dev(${element.var}, "${property_name}", ${should_cache ? last : value});` } else if (property_name) {
: b`${element.var}.${property_name} = ${should_cache ? last : value};`; block.chunks.hydrate.push(
} else { b`${element.var}.${property_name} = ${init};`
block.chunks.hydrate.push( );
b`${method}(${element.var}, "${name}", ${init});` updater = block.renderer.options.dev
); ? b`@prop_dev(${element.var}, "${property_name}", ${should_cache ? last : value});`
updater = b`${method}(${element.var}, "${name}", ${should_cache ? last : value});`; : b`${element.var}.${property_name} = ${should_cache ? last : value};`;
} } else {
block.chunks.hydrate.push(
b`${method}(${element.var}, "${name}", ${init});`
);
updater = b`${method}(${element.var}, "${name}", ${should_cache ? last : value});`;
}
if (dependencies.length > 0) {
let condition = changed(dependencies); let condition = changed(dependencies);
if (should_cache) { if (should_cache) {
condition = x`${condition} && (${last} !== (${last} = ${value}))`; condition = is_src
? x`${condition} && (${element.var}.src !== (${last} = ${value}))`
: x`${condition} && (${last} !== (${last} = ${value}))`;
} }
if (block.has_outros) { if (block.has_outros) {
@ -165,23 +156,11 @@ export default class AttributeWrapper {
if (${condition}) { if (${condition}) {
${updater} ${updater}
}`); }`);
} else { }
const value = this.node.get_value(block);
const statement = (
is_legacy_input_type
? b`@set_input_type(${element.var}, ${value});`
: property_name
? b`${element.var}.${property_name} = ${value};`
: b`${method}(${element.var}, "${name}", ${value.type === 'Literal' && (value as Literal).value === true ? x`""` : value});`
);
block.chunks.hydrate.push(statement);
// special case autofocus. has to be handled in a bit of a weird way // special case autofocus. has to be handled in a bit of a weird way
if (this.node.is_true && name === 'autofocus') { if (this.node.is_true && name === 'autofocus') {
block.autofocus = element.var; block.autofocus = element.var;
}
} }
if (is_indirectly_bound_value) { if (is_indirectly_bound_value) {
@ -199,6 +178,36 @@ export default class AttributeWrapper {
return metadata; return metadata;
} }
get_value(block) {
if (this.node.is_true) {
const metadata = this.get_metadata();
if (metadata && boolean_attribute.has(metadata.property_name.toLowerCase())) {
return x`true`;
}
return x`""`;
}
if (this.node.chunks.length === 0) return x`""`;
// TODO some of this code is repeated in Tag.ts — would be good to
// DRY it out if that's possible without introducing crazy indirection
if (this.node.chunks.length === 1) {
return this.node.chunks[0].type === 'Text'
? string_literal((this.node.chunks[0] as Text).data)
: (this.node.chunks[0] as Expression).manipulate(block);
}
let value = this.node.name === 'class'
? this.get_class_name_text()
: this.render_chunks().reduce((lhs, rhs) => x`${lhs} + ${rhs}`);
// '{foo} {bar}' — treat as string concatenation
if (this.node.chunks[0].type !== 'Text') {
value = x`"" + ${value}`;
}
return value;
}
get_class_name_text() { get_class_name_text() {
const scoped_css = this.node.chunks.some((chunk: Text) => chunk.synthetic); const scoped_css = this.node.chunks.some((chunk: Text) => chunk.synthetic);
const rendered = this.render_chunks(); const rendered = this.render_chunks();
@ -292,3 +301,32 @@ Object.keys(attribute_lookup).forEach(name => {
const metadata = attribute_lookup[name]; const metadata = attribute_lookup[name];
if (!metadata.property_name) metadata.property_name = name; if (!metadata.property_name) metadata.property_name = name;
}); });
// source: https://html.spec.whatwg.org/multipage/indices.html
const boolean_attribute = new Set([
'allowfullscreen',
'allowpaymentrequest',
'async',
'autofocus',
'autoplay',
'checked',
'controls',
'default',
'defer',
'disabled',
'formnovalidate',
'hidden',
'ismap',
'itemscope',
'loop',
'multiple',
'muted',
'nomodule',
'novalidate',
'open',
'playsinline',
'readonly',
'required',
'reversed',
'selected'
]);

@ -121,6 +121,7 @@ export default class ElementWrapper extends Wrapper {
select_binding_dependencies?: Set<string>; select_binding_dependencies?: Set<string>;
var: any; var: any;
void: boolean;
constructor( constructor(
renderer: Renderer, renderer: Renderer,
@ -136,6 +137,8 @@ export default class ElementWrapper extends Wrapper {
name: node.name.replace(/[^a-zA-Z0-9_$]/g, '_') name: node.name.replace(/[^a-zA-Z0-9_$]/g, '_')
}; };
this.void = is_void(node.name);
this.class_dependencies = []; this.class_dependencies = [];
this.attributes = this.node.attributes.map(attribute => { this.attributes = this.node.attributes.map(attribute => {
@ -258,6 +261,7 @@ export default class ElementWrapper extends Wrapper {
const node = this.var; const node = this.var;
const nodes = parent_nodes && block.get_unique_name(`${this.var.name}_nodes`); // if we're in unclaimable territory, i.e. <head>, parent_nodes is null const nodes = parent_nodes && block.get_unique_name(`${this.var.name}_nodes`); // if we're in unclaimable territory, i.e. <head>, parent_nodes is null
const children = x`@children(${this.node.name === 'template' ? x`${node}.content` : node})`;
block.add_variable(node); block.add_variable(node);
const render_statement = this.get_render_statement(); const render_statement = this.get_render_statement();
@ -269,8 +273,13 @@ export default class ElementWrapper extends Wrapper {
if (parent_nodes) { if (parent_nodes) {
block.chunks.claim.push(b` block.chunks.claim.push(b`
${node} = ${this.get_claim_statement(parent_nodes)}; ${node} = ${this.get_claim_statement(parent_nodes)};
var ${nodes} = @children(${this.node.name === 'template' ? x`${node}.content` : node});
`); `);
if (!this.void && this.node.children.length > 0) {
block.chunks.claim.push(b`
var ${nodes} = ${children};
`);
}
} else { } else {
block.chunks.claim.push( block.chunks.claim.push(
b`${node} = ${render_statement};` b`${node} = ${render_statement};`
@ -351,9 +360,9 @@ export default class ElementWrapper extends Wrapper {
this.add_classes(block); this.add_classes(block);
this.add_manual_style_scoping(block); this.add_manual_style_scoping(block);
if (nodes && this.renderer.options.hydratable) { if (nodes && this.renderer.options.hydratable && !this.void) {
block.chunks.claim.push( block.chunks.claim.push(
b`${nodes}.forEach(@detach);` b`${this.node.children.length > 0 ? nodes : children}.forEach(@detach);`
); );
} }
@ -617,7 +626,7 @@ export default class ElementWrapper extends Wrapper {
const snippet = x`{ ${ const snippet = x`{ ${
(metadata && metadata.property_name) || (metadata && metadata.property_name) ||
fix_attribute_casing(attr.node.name) fix_attribute_casing(attr.node.name)
}: ${attr.node.get_value(block)} }`; }: ${attr.get_value(block)} }`;
initial_props.push(snippet); initial_props.push(snippet);
updates.push(condition ? x`${condition} && ${snippet}` : snippet); updates.push(condition ? x`${condition} && ${snippet}` : snippet);
@ -915,7 +924,7 @@ function to_html(wrappers: Array<ElementWrapper | TextWrapper | TagWrapper>, blo
state.quasi.value.raw += '>'; state.quasi.value.raw += '>';
if (!is_void(wrapper.node.name)) { if (!(wrapper as ElementWrapper).void) {
to_html((wrapper as ElementWrapper).fragment.nodes as Array<ElementWrapper | TextWrapper>, block, literal, state); to_html((wrapper as ElementWrapper).fragment.nodes as Array<ElementWrapper | TextWrapper>, block, literal, state);
state.quasi.value.raw += `</${wrapper.node.name}>`; state.quasi.value.raw += `</${wrapper.node.name}>`;

@ -0,0 +1 @@
<p class=" svelte-xyz">Foo</p>

@ -0,0 +1,3 @@
<style>p { color: red; }</style>
<p class={undefined}>Foo</p>

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
attr, attr,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
add_render_callback, add_render_callback,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
add_render_callback, add_render_callback,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
attr, attr,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
create_component, create_component,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
create_component, create_component,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
create_component, create_component,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
create_component, create_component,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
create_component, create_component,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
component_subscribe, component_subscribe,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
function instance($$self, $$props, $$invalidate) { function instance($$self, $$props, $$invalidate) {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteElement, SvelteElement,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
attr, attr,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponentDev, SvelteComponentDev,
add_location, add_location,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponentDev, SvelteComponentDev,
add_location, add_location,
@ -23,6 +24,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (8:0) {#each things as thing}
function create_each_block(ctx) { function create_each_block(ctx) {
let span; let span;
let t0_value = ctx.thing.name + ""; let t0_value = ctx.thing.name + "";

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponentDev, SvelteComponentDev,
add_location, add_location,
@ -23,6 +24,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (6:0) {#each things as thing}
function create_each_block(ctx) { function create_each_block(ctx) {
let span; let span;
let t0_value = ctx.thing.name + ""; let t0_value = ctx.thing.name + "";

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponentDev, SvelteComponentDev,
dispatch_dev, dispatch_dev,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponentDev, SvelteComponentDev,
destroy_each, destroy_each,
@ -21,6 +22,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (4:0) {#each things as thing, index}
function create_each_block(ctx) { function create_each_block(ctx) {
let t0; let t0;
let t1_value = ctx.thing + ""; let t1_value = ctx.thing + "";

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { create_ssr_component, debug, each, escape } from "svelte/internal"; import { create_ssr_component, debug, each, escape } from "svelte/internal";
const Component = create_ssr_component(($$result, $$props, $$bindings, $$slots) => { const Component = create_ssr_component(($$result, $$props, $$bindings, $$slots) => {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,
@ -19,6 +20,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (5:0) {#each createElement as node}
function create_each_block(ctx) { function create_each_block(ctx) {
let span; let span;
let t_value = ctx.node + ""; let t_value = ctx.node + "";

@ -1,4 +1,6 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
import { onMount } from "svelte"; import { onMount } from "svelte";
function instance($$self, $$props, $$invalidate) { function instance($$self, $$props, $$invalidate) {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponentDev, SvelteComponentDev,
add_location, add_location,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
create_component, create_component,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,
@ -19,6 +20,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (9:0) {#each [a, b, c, d, e] as num}
function create_each_block(ctx) { function create_each_block(ctx) {
let span; let span;
let t_value = ctx.num + ""; let t_value = ctx.num + "";

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
HtmlTag, HtmlTag,
SvelteComponent, SvelteComponent,
@ -22,6 +23,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (8:0) {#each comments as comment, i}
function create_each_block(ctx) { function create_each_block(ctx) {
let div; let div;
let strong; let strong;
@ -163,13 +165,7 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent { class Component extends SvelteComponent {
constructor(options) { constructor(options) {
super(); super();
init(this, options, instance, create_fragment, safe_not_equal, { comments: 0, elapsed: 0, time: 0, foo: 0 });
init(this, options, instance, create_fragment, safe_not_equal, {
comments: 0,
elapsed: 0,
time: 0,
foo: 0
});
} }
} }

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,
@ -22,6 +23,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (19:0) {#each things as thing (thing.id)}
function create_each_block(key_1, ctx) { function create_each_block(key_1, ctx) {
let div; let div;
let t_value = ctx.thing.name + ""; let t_value = ctx.thing.name + "";

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,
@ -20,6 +21,7 @@ function get_each_context(ctx, list, i) {
return child_ctx; return child_ctx;
} }
// (5:0) {#each things as thing (thing.id)}
function create_each_block(key_1, ctx) { function create_each_block(key_1, ctx) {
let div; let div;
let t_value = ctx.thing.name + ""; let t_value = ctx.thing.name + "";

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
function instance($$self) { function instance($$self) {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
attr, attr,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -0,0 +1,5 @@
export default {
options: {
hydratable: true
}
};

@ -0,0 +1,64 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
attr,
children,
claim_element,
claim_space,
detach,
element,
init,
insert,
noop,
safe_not_equal,
space
} from "svelte/internal";
function create_fragment(ctx) {
let img;
let img_src_value;
let t;
let div;
return {
c() {
img = element("img");
t = space();
div = element("div");
this.h();
},
l(nodes) {
img = claim_element(nodes, "IMG", { src: true, alt: true });
t = claim_space(nodes);
div = claim_element(nodes, "DIV", {});
children(div).forEach(detach);
this.h();
},
h() {
if (img.src !== (img_src_value = "donuts.jpg")) attr(img, "src", img_src_value);
attr(img, "alt", "donuts");
},
m(target, anchor) {
insert(target, img, anchor);
insert(target, t, anchor);
insert(target, div, anchor);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(img);
if (detaching) detach(t);
if (detaching) detach(div);
}
};
}
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, null, create_fragment, safe_not_equal, {});
}
}
export default Component;

@ -0,0 +1,2 @@
<img src="donuts.jpg" alt="donuts">
<div></div>

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
attr, attr,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,
@ -26,6 +27,7 @@ function create_else_block(ctx) {
}; };
} }
// (5:0) {#if foo}
function create_if_block(ctx) { function create_if_block(ctx) {
let p; let p;

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
attr, attr,
@ -14,6 +15,7 @@ function create_fragment(ctx) {
let div0; let div0;
let t; let t;
let div1; let div1;
let div1_style_value;
return { return {
c() { c() {
@ -21,7 +23,7 @@ function create_fragment(ctx) {
t = space(); t = space();
div1 = element("div"); div1 = element("div");
attr(div0, "style", ctx.style); attr(div0, "style", ctx.style);
attr(div1, "style", "" + (ctx.key + ": " + ctx.value)); attr(div1, "style", div1_style_value = "" + (ctx.key + ": " + ctx.value));
}, },
m(target, anchor) { m(target, anchor) {
insert(target, div0, anchor); insert(target, div0, anchor);
@ -33,8 +35,8 @@ function create_fragment(ctx) {
attr(div0, "style", ctx.style); attr(div0, "style", ctx.style);
} }
if (changed.key || changed.value) { if ((changed.key || changed.value) && div1_style_value !== (div1_style_value = "" + (ctx.key + ": " + ctx.value))) {
attr(div1, "style", "" + (ctx.key + ": " + ctx.value)); attr(div1, "style", div1_style_value);
} }
}, },
i: noop, i: noop,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
attr, attr,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,
@ -70,11 +71,7 @@ function instance($$self, $$props, $$invalidate) {
$$invalidate("test", test); $$invalidate("test", test);
} }
return { return { test, handleSubmit, input_input_handler };
test,
handleSubmit,
input_input_handler
};
} }
class Component extends SvelteComponent { class Component extends SvelteComponent {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
attr, attr,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
attr, attr,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
add_render_callback, add_render_callback,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
create_component, create_component,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
function instance($$self, $$props, $$invalidate) { function instance($$self, $$props, $$invalidate) {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
function instance($$self, $$props, $$invalidate) { function instance($$self, $$props, $$invalidate) {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,4 +1,6 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal"; import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
const SOME_CONSTANT = 42; const SOME_CONSTANT = 42;
function foo(bar) { function foo(bar) {

@ -0,0 +1,5 @@
export default {
options: {
hydratable: true
}
};

@ -0,0 +1,85 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
attr,
claim_element,
claim_space,
detach,
element,
init,
insert,
noop,
safe_not_equal,
space
} from "svelte/internal";
function create_fragment(ctx) {
let img0;
let img0_src_value;
let t;
let img1;
let img1_src_value;
return {
c() {
img0 = element("img");
t = space();
img1 = element("img");
this.h();
},
l(nodes) {
img0 = claim_element(nodes, "IMG", { alt: true, src: true });
t = claim_space(nodes);
img1 = claim_element(nodes, "IMG", { alt: true, src: true });
this.h();
},
h() {
attr(img0, "alt", "potato");
if (img0.src !== (img0_src_value = ctx.url)) attr(img0, "src", img0_src_value);
attr(img1, "alt", "potato");
if (img1.src !== (img1_src_value = "" + (ctx.slug + ".jpg"))) attr(img1, "src", img1_src_value);
},
m(target, anchor) {
insert(target, img0, anchor);
insert(target, t, anchor);
insert(target, img1, anchor);
},
p(changed, ctx) {
if (changed.url && img0.src !== (img0_src_value = ctx.url)) {
attr(img0, "src", img0_src_value);
}
if (changed.slug && img1.src !== (img1_src_value = "" + (ctx.slug + ".jpg"))) {
attr(img1, "src", img1_src_value);
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(img0);
if (detaching) detach(t);
if (detaching) detach(img1);
}
};
}
function instance($$self, $$props, $$invalidate) {
let { url } = $$props;
let { slug } = $$props;
$$self.$set = $$props => {
if ("url" in $$props) $$invalidate("url", url = $$props.url);
if ("slug" in $$props) $$invalidate("slug", slug = $$props.slug);
};
return { url, slug };
}
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { url: 0, slug: 0 });
}
}
export default Component;

@ -0,0 +1,7 @@
<script>
export let url;
export let slug;
</script>
<img alt="potato" src={url}>
<img alt="potato" src="{slug}.jpg">

@ -1,4 +1,6 @@
/* generated by Svelte vX.Y.Z */
import { create_ssr_component } from "svelte/internal"; import { create_ssr_component } from "svelte/internal";
import { onDestroy, onMount } from "svelte"; import { onDestroy, onMount } from "svelte";
function preload(input) { function preload(input) {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { create_ssr_component } from "svelte/internal"; import { create_ssr_component } from "svelte/internal";
const Component = create_ssr_component(($$result, $$props, $$bindings, $$slots) => { const Component = create_ssr_component(($$result, $$props, $$bindings, $$slots) => {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal"; import { SvelteComponent, init, noop, safe_not_equal } from "svelte/internal";
function create_fragment(ctx) { function create_fragment(ctx) {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
add_render_callback, add_render_callback,
@ -47,6 +48,7 @@ function create_if_block(ctx) {
}; };
} }
// (9:1) {#if y}
function create_if_block_1(ctx) { function create_if_block_1(ctx) {
let div; let div;
let div_intro; let div_intro;

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
check_outros, check_outros,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
append, append,
@ -28,6 +29,7 @@ function create_if_block_4(ctx) {
}; };
} }
// (16:1) {#if b}
function create_if_block_3(ctx) { function create_if_block_3(ctx) {
let p; let p;
@ -45,6 +47,7 @@ function create_if_block_3(ctx) {
}; };
} }
// (20:1) {#if c}
function create_if_block_2(ctx) { function create_if_block_2(ctx) {
let p; let p;
@ -62,6 +65,7 @@ function create_if_block_2(ctx) {
}; };
} }
// (26:1) {#if d}
function create_if_block_1(ctx) { function create_if_block_1(ctx) {
let p; let p;
@ -79,6 +83,7 @@ function create_if_block_1(ctx) {
}; };
} }
// (33:0) {#if e}
function create_if_block(ctx) { function create_if_block(ctx) {
let p; let p;

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
add_render_callback, add_render_callback,

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
add_render_callback, add_render_callback,

@ -0,0 +1,15 @@
<script>
export let options = [];
export let index = 0;
export let value;
$: {
value = options[index];
}
</script>
<select bind:value={index}>
{#each options as option, i}
<option value={i}>{option}</option>
{/each}
</select>

@ -0,0 +1,19 @@
export default {
async test({ assert, component, target }) {
assert.htmlEqual(target.innerHTML, 'Loading...');
await component.promise;
const span = target.querySelector('span');
assert.equal(span.textContent, 'a');
const select = target.querySelector('select');
const options = [...target.querySelectorAll('option')];
const change = new window.Event('change');
options[1].selected = true;
await select.dispatchEvent(change);
assert.equal(span.textContent, 'b');
}
};

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save