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
},
"code-red": {
"version": "0.0.18",
"resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.18.tgz",
"integrity": "sha512-g7W6RwRqBbQTtMaUqrNWDyyl2GK0Uulk/uZPzGdgTXpOGX/LA8bW67EKQLdQgpYfd6APhZVwoX2lrL7mnJOWkA==",
"version": "0.0.19",
"resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.19.tgz",
"integrity": "sha512-pzkA9ikMLR7KatByUJVz33kQKkrDnsJhyuvxSSUnyJNBggkGNStmDe/ezYvfP4CZ9XM7vYIID+YIaMJnlYGzLg==",
"dev": true,
"requires": {
"acorn": "^7.1.0",

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

@ -6,7 +6,9 @@ authorURL: https://twitter.com/Rich_Harris
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
* svelte-vscode
@ -14,7 +16,7 @@ draft: true
## 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
"*":
@ -45,3 +47,23 @@ To set the filetype for a single file, use a [modeline](https://vim.fandom.com/w
```
<!-- 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
<Keypad bind:value={pin}/>

@ -33,7 +33,7 @@
font-family: 'Overpass';
letter-spacing: 0.12em;
color: #676778;
font-weight: 100;
font-weight: 400;
}
.centered span {
@ -71,4 +71,4 @@
toggle me
</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;
}
```
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>
```
> 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`:

@ -240,8 +240,7 @@ export default class Component {
const { compile_options, name } = this;
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 };

@ -44,7 +44,7 @@ function edit_source(source, sveltePath) {
function esm(
program: any,
name: Identifier,
_banner: string,
banner: string,
sveltePath: string,
internal_path: string,
helpers: Array<{ name: string; alias: Identifier }>,
@ -98,6 +98,8 @@ function esm(
};
program.body = b`
/* ${banner} */
${import_declaration}
${internal_globals}
${imports}
@ -112,7 +114,7 @@ function esm(
function cjs(
program: any,
name: Identifier,
_banner: string,
banner: string,
sveltePath: string,
internal_path: string,
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 }};`);
program.body = b`
/* ${banner} */
"use strict";
${internal_requires}
${internal_globals}

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

@ -7,7 +7,6 @@ import { b, x } from 'code-red';
import Expression from '../../../nodes/shared/Expression';
import Text from '../../../nodes/Text';
import { changed } from '../shared/changed';
import { Literal } from 'estree';
export default class AttributeWrapper {
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 dependencies = this.node.get_dependencies();
if (dependencies.length > 0) {
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 value = this.get_value(block);
const is_select_value_attribute =
name === 'value' && element.node.name === 'select';
const is_src = this.node.name === 'src'; // TODO retire this exception in favour of https://github.com/sveltejs/svelte/issues/3750
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(
`${element.var.name}_${name.replace(/[^a-zA-Z_$]/g, '_')}_value`
);
const last = should_cache && block.get_unique_name(
`${element.var.name}_${name.replace(/[^a-zA-Z_$]/g, '_')}_value`
);
if (should_cache) block.add_variable(last);
let updater;
const init = should_cache ? x`${last} = ${value}` : value;
if (is_legacy_input_type) {
block.chunks.hydrate.push(
b`@set_input_type(${element.var}, ${init});`
);
updater = b`@set_input_type(${element.var}, ${should_cache ? last : value});`;
} else if (is_select_value_attribute) {
// annoying special case
const is_multiple_select = element.node.get_static_attribute_value('multiple');
const i = block.get_unique_name('i');
const option = block.get_unique_name('option');
const if_statement = is_multiple_select
? b`
${option}.selected = ~${last}.indexOf(${option}.__value);`
: b`
if (${option}.__value === ${last}) {
${option}.selected = true;
${{ type: 'BreakStatement' }};
}`; // TODO the BreakStatement is gross, but it's unsyntactic otherwise...
updater = b`
for (var ${i} = 0; ${i} < ${element.var}.options.length; ${i} += 1) {
var ${option} = ${element.var}.options[${i}];
${if_statement}
}
`;
block.chunks.mount.push(b`
${last} = ${value};
${updater}
`);
} else if (property_name) {
block.chunks.hydrate.push(
b`${element.var}.${property_name} = ${init};`
);
updater = block.renderer.options.dev
? b`@prop_dev(${element.var}, "${property_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 (should_cache) block.add_variable(last);
let updater;
const init = should_cache ? x`${last} = ${value}` : value;
if (is_legacy_input_type) {
block.chunks.hydrate.push(
b`@set_input_type(${element.var}, ${init});`
);
updater = b`@set_input_type(${element.var}, ${should_cache ? last : value});`;
} else if (is_select_value_attribute) {
// annoying special case
const is_multiple_select = element.node.get_static_attribute_value('multiple');
const i = block.get_unique_name('i');
const option = block.get_unique_name('option');
const if_statement = is_multiple_select
? b`
${option}.selected = ~${last}.indexOf(${option}.__value);`
: b`
if (${option}.__value === ${last}) {
${option}.selected = true;
${{ type: 'BreakStatement' }};
}`; // TODO the BreakStatement is gross, but it's unsyntactic otherwise...
updater = b`
for (var ${i} = 0; ${i} < ${element.var}.options.length; ${i} += 1) {
var ${option} = ${element.var}.options[${i}];
${if_statement}
}
`;
block.chunks.mount.push(b`
${last} = ${value};
${updater}
`);
} else if (is_src) {
block.chunks.hydrate.push(
b`if (${element.var}.src !== ${init}) ${method}(${element.var}, "${name}", ${last});`
);
updater = b`${method}(${element.var}, "${name}", ${should_cache ? last : value});`;
} else if (property_name) {
block.chunks.hydrate.push(
b`${element.var}.${property_name} = ${init};`
);
updater = block.renderer.options.dev
? b`@prop_dev(${element.var}, "${property_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);
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) {
@ -165,23 +156,11 @@ export default class AttributeWrapper {
if (${condition}) {
${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
if (this.node.is_true && name === 'autofocus') {
block.autofocus = element.var;
}
// special case autofocus. has to be handled in a bit of a weird way
if (this.node.is_true && name === 'autofocus') {
block.autofocus = element.var;
}
if (is_indirectly_bound_value) {
@ -199,6 +178,36 @@ export default class AttributeWrapper {
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() {
const scoped_css = this.node.chunks.some((chunk: Text) => chunk.synthetic);
const rendered = this.render_chunks();
@ -292,3 +301,32 @@ Object.keys(attribute_lookup).forEach(name => {
const metadata = attribute_lookup[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>;
var: any;
void: boolean;
constructor(
renderer: Renderer,
@ -136,6 +137,8 @@ export default class ElementWrapper extends Wrapper {
name: node.name.replace(/[^a-zA-Z0-9_$]/g, '_')
};
this.void = is_void(node.name);
this.class_dependencies = [];
this.attributes = this.node.attributes.map(attribute => {
@ -258,6 +261,7 @@ export default class ElementWrapper extends Wrapper {
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 children = x`@children(${this.node.name === 'template' ? x`${node}.content` : node})`;
block.add_variable(node);
const render_statement = this.get_render_statement();
@ -269,8 +273,13 @@ export default class ElementWrapper extends Wrapper {
if (parent_nodes) {
block.chunks.claim.push(b`
${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 {
block.chunks.claim.push(
b`${node} = ${render_statement};`
@ -351,9 +360,9 @@ export default class ElementWrapper extends Wrapper {
this.add_classes(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(
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`{ ${
(metadata && metadata.property_name) ||
fix_attribute_casing(attr.node.name)
}: ${attr.node.get_value(block)} }`;
}: ${attr.get_value(block)} }`;
initial_props.push(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 += '>';
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);
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 {
SvelteComponent,
detach,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponentDev,
destroy_each,
@ -21,6 +22,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}
// (4:0) {#each things as thing, index}
function create_each_block(ctx) {
let t0;
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";
const Component = create_ssr_component(($$result, $$props, $$bindings, $$slots) => {

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
@ -19,6 +20,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}
// (5:0) {#each createElement as node}
function create_each_block(ctx) {
let span;
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 { onMount } from "svelte";
function instance($$self, $$props, $$invalidate) {

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

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

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

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

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
HtmlTag,
SvelteComponent,
@ -22,6 +23,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}
// (8:0) {#each comments as comment, i}
function create_each_block(ctx) {
let div;
let strong;
@ -163,13 +165,7 @@ function instance($$self, $$props, $$invalidate) {
class Component extends SvelteComponent {
constructor(options) {
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 {
SvelteComponent,
append,
@ -22,6 +23,7 @@ function get_each_context(ctx, list, i) {
return child_ctx;
}
// (19:0) {#each things as thing (thing.id)}
function create_each_block(key_1, ctx) {
let div;
let t_value = ctx.thing.name + "";

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

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

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

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

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

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

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
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 {
SvelteComponent,
attr,

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -1,4 +1,6 @@
/* generated by Svelte vX.Y.Z */
import { SvelteComponent, init, safe_not_equal } from "svelte/internal";
const SOME_CONSTANT = 42;
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 { onDestroy, onMount } from "svelte";
function preload(input) {

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

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

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

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

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

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

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

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

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

@ -1,3 +1,4 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
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