Merge branch 'master' into pr/5289

pull/5289/head
Conduitry 5 years ago
commit b55dc5973a

@ -8,10 +8,13 @@ the issue. One way we prioritize issues is by the number of :+1: reactions on
their descriptions. Please DO NOT add `+1` or :+1: comments. their descriptions. Please DO NOT add `+1` or :+1: comments.
### Feature requests and proposals ### Feature requests and proposals
We're excited to hear how we can make Svelte better. Please add as much detail We're excited to hear how we can make Svelte better. Please add as much detail
as you can on your use case. as you can on your use case. To propose an implementation of a large feature or
change, please create an [RFC](https://github.com/sveltejs/rfcs).
### Bugs ### Bugs
If you're filing an issue about a bug please include as much information If you're filing an issue about a bug please include as much information
as you can including the following. as you can including the following.

@ -7,6 +7,11 @@ assignees: ''
--- ---
<!--
If you'd like to propose an implementation for a large new feature or change then please create an RFC:
https://github.com/sveltejs/rfcs
-->
**Is your feature request related to a problem? Please describe.** **Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. For example: I'm always frustrated when [...] A clear and concise description of what the problem is. For example: I'm always frustrated when [...]

@ -1,8 +1,7 @@
### Before submitting the PR, please make sure you do the following ### Before submitting the PR, please make sure you do the following
- [ ] It's really useful if your PR relates to an outstanding issue, so please reference it in your PR, or create an explanatory one for discussion. In many cases, features are absent for a reason. - [ ] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
- [ ] This message body should clearly illustrate what problems it solves. If there are related issues, remember to reference them. - [ ] This message body should clearly illustrate what problems it solves.
- [ ] Ideally, include a test that fails without this PR but passes with it. PRs will only be merged once they pass CI. (Remember to `npm run lint`!) - [ ] Ideally, include a test that fails without this PR but passes with it.
### Tests ### Tests
- [ ] Run the tests with `npm test` or `yarn test`) - [ ] Run the tests with `npm test` and lint the project with `npm run lint`

@ -3,11 +3,13 @@
## Unreleased ## Unreleased
* Expose object of which slots have received content in `$$slots` ([#2106](https://github.com/sveltejs/svelte/issues/2106)) * Expose object of which slots have received content in `$$slots` ([#2106](https://github.com/sveltejs/svelte/issues/2106))
* Re-throw an unhandled rejection when an `{#await}` block with no `{:catch}` gets a rejection ([#5129](https://github.com/sveltejs/svelte/issues/5129))
* Add types to `createEventDispatcher` ([#5211](https://github.com/sveltejs/svelte/issues/5211)) * Add types to `createEventDispatcher` ([#5211](https://github.com/sveltejs/svelte/issues/5211))
* In SSR mode, do not automatically declare variables for reactive assignments to member expressions ([#5247](https://github.com/sveltejs/svelte/issues/5247)) * In SSR mode, do not automatically declare variables for reactive assignments to member expressions ([#5247](https://github.com/sveltejs/svelte/issues/5247))
* Include selector in message of `unused-css-selector` warning ([#5252](https://github.com/sveltejs/svelte/issues/5252)) * Include selector in message of `unused-css-selector` warning ([#5252](https://github.com/sveltejs/svelte/issues/5252))
* Fix using `<Namespaced.Component/>`s in child `{#await}`/`{#each}` contexts ([#5255](https://github.com/sveltejs/svelte/issues/5255)) * Fix using `<Namespaced.Component/>`s in child `{#await}`/`{#each}` contexts ([#5255](https://github.com/sveltejs/svelte/issues/5255))
* Fix using `<svelte:component>` in `{:catch}` ([#5259](https://github.com/sveltejs/svelte/issues/5259)) * Fix using `<svelte:component>` in `{:catch}` ([#5259](https://github.com/sveltejs/svelte/issues/5259))
* Fix setting one-way bound `<input>` `value` to `undefined` when it has spread attributes ([#5270](https://github.com/sveltejs/svelte/issues/5270))
## 3.24.1 ## 3.24.1

@ -43,13 +43,16 @@ When [opening a new issue](https://github.com/sveltejs/svelte/issues/new/choose)
- **One issue, one bug:** Please report a single bug per issue. - **One issue, one bug:** Please report a single bug per issue.
- **Provide reproduction steps:** List all the steps necessary to reproduce the issue. The person reading your bug report should be able to follow these steps to reproduce your issue with minimal effort. If possible, use the [REPL](https://svelte.dev/repl) to create your reproduction. - **Provide reproduction steps:** List all the steps necessary to reproduce the issue. The person reading your bug report should be able to follow these steps to reproduce your issue with minimal effort. If possible, use the [REPL](https://svelte.dev/repl) to create your reproduction.
## RFCs
If you'd like to propose an implementation for a large new feature or change then please [create an RFC](https://github.com/sveltejs/rfcs) to discuss it up front.
## Installation ## Installation
1. Ensure you have [npm](https://www.npmjs.com/get-npm) installed. 1. Ensure you have [npm](https://www.npmjs.com/get-npm) installed.
1. After cloning the repository, run `npm install` in the root of the repository. 1. After cloning the repository, run `npm install` in the root of the repository.
1. To start a development server, run `npm run dev`. 1. To start a development server, run `npm run dev`.
## Pull requests ## Pull requests
### Your first pull request ### Your first pull request

4
package-lock.json generated

@ -144,8 +144,8 @@
} }
}, },
"@sveltejs/eslint-config": { "@sveltejs/eslint-config": {
"version": "github:sveltejs/eslint-config#e8a9b27cd3f7aa66388474412b1a5c11c5a44ade", "version": "github:sveltejs/eslint-config#848ce6464a9ae9c2f3a3095474701dfe9ab851df",
"from": "github:sveltejs/eslint-config#v0.0.1", "from": "github:sveltejs/eslint-config#v5.0.0",
"dev": true "dev": true
}, },
"@tootallnate/once": { "@tootallnate/once": {

@ -63,7 +63,7 @@
"@rollup/plugin-sucrase": "^3.0.0", "@rollup/plugin-sucrase": "^3.0.0",
"@rollup/plugin-typescript": "^2.0.1", "@rollup/plugin-typescript": "^2.0.1",
"@rollup/plugin-virtual": "^2.0.0", "@rollup/plugin-virtual": "^2.0.0",
"@sveltejs/eslint-config": "github:sveltejs/eslint-config#v0.0.1", "@sveltejs/eslint-config": "github:sveltejs/eslint-config#v5.0.0",
"@types/mocha": "^5.2.7", "@types/mocha": "^5.2.7",
"@types/node": "^8.10.53", "@types/node": "^8.10.53",
"@typescript-eslint/eslint-plugin": "^3.0.2", "@typescript-eslint/eslint-plugin": "^3.0.2",

@ -107,7 +107,7 @@ Your `include`/`exclude` may differ per project — these are defaults that shou
Any editor [using an LSP](https://langserver.org/#implementations-client) can be supported. The [VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) extension has been our primary focus, but there is work in progress [on Atom](https://github.com/sveltejs/language-tools/pull/160), and Vim via [coc-svelte](https://github.com/coc-extensions/coc-svelte) has been updated with the latest LSP. Any editor [using an LSP](https://langserver.org/#implementations-client) can be supported. The [VS Code](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) extension has been our primary focus, but there is work in progress [on Atom](https://github.com/sveltejs/language-tools/pull/160), and Vim via [coc-svelte](https://github.com/coc-extensions/coc-svelte) has been updated with the latest LSP.
These editor extensions will improve your coding experience even if you only use JavaScript. The editor won't offer errors, but it will offer inference and refactoring tools. You can [add `// @check-js`](https://www.staging-typescript.org/docs/handbook/intro-to-js-ts.html) to the top of a `<script>` tag using JavaScript to get better error messages with no infra changes. These editor extensions will improve your coding experience even if you only use JavaScript. The editor won't offer errors, but it will offer inference and refactoring tools. You can [add `// @ts-check`](https://www.staging-typescript.org/docs/handbook/intro-to-js-ts.html) to the top of a `<script>` tag using JavaScript to get better error messages with no infra changes.
To switch a `<script>` to use TypeScript, use `<script lang="ts">` and that should be it. Hopefully you won't be seeing an ocean of red squiggles. To switch a `<script>` to use TypeScript, use `<script lang="ts">` and that should be it. Hopefully you won't be seeing an ocean of red squiggles.

@ -8,7 +8,7 @@ import {
create_scopes, create_scopes,
extract_names, extract_names,
Scope, Scope,
extract_identifiers, extract_identifiers
} from './utils/scope'; } from './utils/scope';
import Stylesheet from './css/Stylesheet'; import Stylesheet from './css/Stylesheet';
import { test } from '../config'; import { test } from '../config';
@ -155,7 +155,7 @@ export default class Component {
) || { start: 0, end: 0 }; ) || { start: 0, end: 0 };
this.warn(svelteOptions, { this.warn(svelteOptions, {
code: 'custom-element-no-tag', code: 'custom-element-no-tag',
message: `No custom element 'tag' option was specified. To automatically register a custom element, specify a name with a hyphen in it, e.g. <svelte:options tag="my-thing"/>. To hide this warning, use <svelte:options tag={null}/>`, message: `No custom element 'tag' option was specified. To automatically register a custom element, specify a name with a hyphen in it, e.g. <svelte:options tag="my-thing"/>. To hide this warning, use <svelte:options tag={null}/>`
}); });
} }
this.tag = this.component_options.tag || compile_options.tag; this.tag = this.component_options.tag || compile_options.tag;
@ -190,7 +190,7 @@ export default class Component {
this.add_var({ this.add_var({
name, name,
injected: true, injected: true,
referenced: true, referenced: true
}); });
} else if (name[0] === '$') { } else if (name[0] === '$') {
this.add_var({ this.add_var({
@ -198,7 +198,7 @@ export default class Component {
injected: true, injected: true,
referenced: true, referenced: true,
mutated: true, mutated: true,
writable: true, writable: true
}); });
const subscribable_name = name.slice(1); const subscribable_name = name.slice(1);
@ -289,7 +289,7 @@ export default class Component {
} }
const imported_helpers = Array.from(this.helpers, ([name, alias]) => ({ const imported_helpers = Array.from(this.helpers, ([name, alias]) => ({
name, name,
alias, alias
})); }));
create_module( create_module(
@ -305,7 +305,7 @@ export default class Component {
.filter(variable => variable.module && variable.export_name) .filter(variable => variable.module && variable.export_name)
.map(variable => ({ .map(variable => ({
name: variable.name, name: variable.name,
as: variable.export_name, as: variable.export_name
})) }))
); );
@ -342,9 +342,9 @@ export default class Component {
reassigned: v.reassigned || false, reassigned: v.reassigned || false,
referenced: v.referenced || false, referenced: v.referenced || false,
writable: v.writable || false, writable: v.writable || false,
referenced_from_script: v.referenced_from_script || false, referenced_from_script: v.referenced_from_script || false
})), })),
stats: this.stats.render(), stats: this.stats.render()
}; };
} }
@ -409,7 +409,7 @@ export default class Component {
source: this.source, source: this.source,
start: pos.start, start: pos.start,
end: pos.end, end: pos.end,
filename: this.compile_options.filename, filename: this.compile_options.filename
}); });
} }
@ -441,7 +441,7 @@ export default class Component {
pos: pos.start, pos: pos.start,
filename: this.compile_options.filename, filename: this.compile_options.filename,
toString: () => toString: () =>
`${warning.message} (${start.line}:${start.column})\n${frame}`, `${warning.message} (${start.line}:${start.column})\n${frame}`
}); });
} }
@ -453,7 +453,7 @@ export default class Component {
if (node.type === 'ExportDefaultDeclaration') { if (node.type === 'ExportDefaultDeclaration') {
this.error(node, { this.error(node, {
code: `default-export`, code: `default-export`,
message: `A component cannot have a default export`, message: `A component cannot have a default export`
}); });
} }
@ -461,7 +461,7 @@ export default class Component {
if (node.source) { if (node.source) {
this.error(node, { this.error(node, {
code: `not-implemented`, code: `not-implemented`,
message: `A component currently cannot have an export ... from`, message: `A component currently cannot have an export ... from`
}); });
} }
if (node.declaration) { if (node.declaration) {
@ -531,10 +531,10 @@ export default class Component {
if (node.type === 'LabeledStatement' && node.label.name === '$') { if (node.type === 'LabeledStatement' && node.label.name === '$') {
component.warn(node as any, { component.warn(node as any, {
code: 'module-script-reactive-declaration', code: 'module-script-reactive-declaration',
message: '$: has no effect in a module script', message: '$: has no effect in a module script'
}); });
} }
}, }
}); });
const { scope, globals } = create_scopes(script.content); const { scope, globals } = create_scopes(script.content);
@ -544,7 +544,7 @@ export default class Component {
if (name[0] === '$') { if (name[0] === '$') {
this.error(node as any, { this.error(node as any, {
code: 'illegal-declaration', code: 'illegal-declaration',
message: `The $ prefix is reserved, and cannot be used for variable and import names`, message: `The $ prefix is reserved, and cannot be used for variable and import names`
}); });
} }
@ -562,7 +562,7 @@ export default class Component {
if (name[0] === '$') { if (name[0] === '$') {
this.error(node as any, { this.error(node as any, {
code: 'illegal-subscription', code: 'illegal-subscription',
message: `Cannot reference store value inside <script context="module">`, message: `Cannot reference store value inside <script context="module">`
}); });
} else { } else {
this.add_var({ this.add_var({
@ -623,7 +623,7 @@ export default class Component {
if (name[0] === '$') { if (name[0] === '$') {
this.error(node as any, { this.error(node as any, {
code: 'illegal-declaration', code: 'illegal-declaration',
message: `The $ prefix is reserved, and cannot be used for variable and import names`, message: `The $ prefix is reserved, and cannot be used for variable and import names`
}); });
} }
@ -647,12 +647,12 @@ export default class Component {
injected: true, injected: true,
writable: true, writable: true,
reassigned: true, reassigned: true,
initialised: true, initialised: true
}); });
} else if (is_reserved_keyword(name)) { } else if (is_reserved_keyword(name)) {
this.add_var({ this.add_var({
name, name,
injected: true, injected: true
}); });
} else if (name[0] === '$') { } else if (name[0] === '$') {
if (name === '$' || name[1] === '$') { if (name === '$' || name[1] === '$') {
@ -666,7 +666,7 @@ export default class Component {
name, name,
injected: true, injected: true,
mutated: true, mutated: true,
writable: true, writable: true
}); });
this.add_reference(name.slice(1)); this.add_reference(name.slice(1));
@ -764,7 +764,7 @@ export default class Component {
if (map.has(node)) { if (map.has(node)) {
scope = scope.parent; scope = scope.parent;
} }
}, }
}); });
for (const [parent, prop, index] of to_remove) { for (const [parent, prop, index] of to_remove) {
@ -832,7 +832,7 @@ export default class Component {
if (map.has(node)) { if (map.has(node)) {
scope = scope.parent; scope = scope.parent;
} }
}, }
}); });
} }
@ -844,7 +844,7 @@ export default class Component {
) { ) {
this.warn(node as any, { this.warn(node as any, {
code: 'non-top-level-reactive-declaration', code: 'non-top-level-reactive-declaration',
message: '$: has no effect outside of the top-level', message: '$: has no effect outside of the top-level'
}); });
} }
@ -881,7 +881,7 @@ export default class Component {
if (node.body.type !== 'BlockStatement') { if (node.body.type !== 'BlockStatement') {
node.body = { node.body = {
type: 'BlockStatement', type: 'BlockStatement',
body: [node.body], body: [node.body]
}; };
} }
node.body.body.push(inside[0]); node.body.body.push(inside[0]);
@ -890,8 +890,8 @@ export default class Component {
type: 'BlockStatement', type: 'BlockStatement',
body: [ body: [
before[0], before[0],
node, node
], ]
}; };
} }
return null; return null;
@ -927,7 +927,7 @@ export default class Component {
// TODO is this still true post-#3539? // TODO is this still true post-#3539?
component.error(declarator as any, { component.error(declarator as any, {
code: 'destructured-prop', code: 'destructured-prop',
message: `Cannot declare props in destructured declaration`, message: `Cannot declare props in destructured declaration`
}); });
} }
@ -990,7 +990,7 @@ export default class Component {
if (node.type === 'ExportNamedDeclaration' && node.declaration) { if (node.type === 'ExportNamedDeclaration' && node.declaration) {
(parent as Program).body[index] = node.declaration; (parent as Program).body[index] = node.declaration;
} }
}, }
}); });
} }
@ -1004,7 +1004,7 @@ export default class Component {
hoistable_nodes, hoistable_nodes,
var_lookup, var_lookup,
injected_reactive_declaration_vars, injected_reactive_declaration_vars,
imports, imports
} = this; } = this;
const top_level_function_declarations = new Map(); const top_level_function_declarations = new Map();
@ -1136,7 +1136,7 @@ export default class Component {
if (map.has(node)) { if (map.has(node)) {
scope = scope.parent; scope = scope.parent;
} }
}, }
}); });
checked.add(fn_declaration); checked.add(fn_declaration);
@ -1229,7 +1229,7 @@ export default class Component {
if (map.has(node)) { if (map.has(node)) {
scope = scope.parent; scope = scope.parent;
} }
}, }
}); });
const { expression } = node.body as ExpressionStatement; const { expression } = node.body as ExpressionStatement;
@ -1239,7 +1239,7 @@ export default class Component {
assignees, assignees,
dependencies, dependencies,
node, node,
declaration, declaration
}); });
} }
}); });
@ -1320,7 +1320,7 @@ export default class Component {
this.warn(node, { this.warn(node, {
code: 'missing-declaration', code: 'missing-declaration',
message, message
}); });
} }
@ -1343,7 +1343,7 @@ function process_component_options(component: Component, nodes) {
'accessors' in component.compile_options 'accessors' in component.compile_options
? component.compile_options.accessors ? component.compile_options.accessors
: !!component.compile_options.customElement, : !!component.compile_options.customElement,
preserveWhitespace: !!component.compile_options.preserveWhitespace, preserveWhitespace: !!component.compile_options.preserveWhitespace
}; };
const node = nodes.find(node => node.name === 'svelte:options'); const node = nodes.find(node => node.name === 'svelte:options');
@ -1384,7 +1384,7 @@ function process_component_options(component: Component, nodes) {
if (tag && !/^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/.test(tag)) { if (tag && !/^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/.test(tag)) {
component.error(attribute, { component.error(attribute, {
code: `invalid-tag-property`, code: `invalid-tag-property`,
message: `tag name must be two or more words joined by the '-' character`, message: `tag name must be two or more words joined by the '-' character`
}); });
} }
@ -1412,12 +1412,12 @@ function process_component_options(component: Component, nodes) {
if (match) { if (match) {
component.error(attribute, { component.error(attribute, {
code: `invalid-namespace-property`, code: `invalid-namespace-property`,
message: `Invalid namespace '${ns}' (did you mean '${match}'?)`, message: `Invalid namespace '${ns}' (did you mean '${match}'?)`
}); });
} else { } else {
component.error(attribute, { component.error(attribute, {
code: `invalid-namespace-property`, code: `invalid-namespace-property`,
message: `Invalid namespace '${ns}'`, message: `Invalid namespace '${ns}'`
}); });
} }
} }
@ -1443,13 +1443,13 @@ function process_component_options(component: Component, nodes) {
default: default:
component.error(attribute, { component.error(attribute, {
code: `invalid-options-attribute`, code: `invalid-options-attribute`,
message: `<svelte:options> unknown attribute`, message: `<svelte:options> unknown attribute`
}); });
} }
} else { } else {
component.error(attribute, { component.error(attribute, {
code: `invalid-options-attribute`, code: `invalid-options-attribute`,
message: `<svelte:options> can only have static 'tag', 'namespace', 'accessors', 'immutable' and 'preserveWhitespace' attributes`, message: `<svelte:options> can only have static 'tag', 'namespace', 'accessors', 'immutable' and 'preserveWhitespace' attributes`
}); });
} }
}); });

@ -52,7 +52,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
code: `options-lowercase-name`, code: `options-lowercase-name`,
message, message,
filename, filename,
toString: () => message, toString: () => message
}); });
} }
@ -62,7 +62,7 @@ function validate_options(options: CompileOptions, warnings: Warning[]) {
code: `options-loop-guard-timeout`, code: `options-loop-guard-timeout`,
message, message,
filename, filename,
toString: () => message, toString: () => message
}); });
} }
} }

@ -76,7 +76,7 @@ export default class Binding extends Node {
if (info.expression.type === 'Identifier' && !variable.writable) component.error(this.expression.node, { if (info.expression.type === 'Identifier' && !variable.writable) component.error(this.expression.node, {
code: 'invalid-binding', code: 'invalid-binding',
message: 'Cannot bind to a variable which is not writable', message: 'Cannot bind to a variable which is not writable'
}); });
} }

@ -399,7 +399,7 @@ export default class Element extends Node {
if (/(^[0-9-.])|[\^$@%&#?!|()[\]{}^*+~;]/.test(name)) { if (/(^[0-9-.])|[\^$@%&#?!|()[\]{}^*+~;]/.test(name)) {
component.error(attribute, { component.error(attribute, {
code: `illegal-attribute`, code: `illegal-attribute`,
message: `'${name}' is not a valid attribute name`, message: `'${name}' is not a valid attribute name`
}); });
} }
@ -423,7 +423,7 @@ export default class Element extends Node {
if (!(parent.type === 'InlineComponent' || within_custom_element(parent))) { if (!(parent.type === 'InlineComponent' || within_custom_element(parent))) {
component.error(attribute, { component.error(attribute, {
code: `invalid-slotted-content`, code: `invalid-slotted-content`,
message: `Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`, message: `Element with a slot='...' attribute must be a child of a component or a descendant of a custom element`
}); });
} }
} }

@ -12,7 +12,7 @@ const elements_without_text = new Set([
'dl', 'dl',
'optgroup', 'optgroup',
'select', 'select',
'video', 'video'
]); ]);
export default class Text extends Node { export default class Text extends Node {

@ -101,7 +101,7 @@ export default class Block {
intro: [], intro: [],
update: [], update: [],
outro: [], outro: [],
destroy: [], destroy: []
}; };
this.has_animation = false; this.has_animation = false;

@ -76,7 +76,7 @@ export default class Renderer {
bindings: new Map(), bindings: new Map(),
dependencies: new Set(), dependencies: new Set()
}); });
this.block.has_update_method = true; this.block.has_update_method = true;

@ -188,6 +188,7 @@ export default class AwaitBlockWrapper extends Wrapper {
ctx: #ctx, ctx: #ctx,
current: null, current: null,
token: null, token: null,
hasCatch: ${this.catch.node.start !== null ? 'true' : 'false'},
pending: ${this.pending.block.name}, pending: ${this.pending.block.name},
then: ${this.then.block.name}, then: ${this.then.block.name},
catch: ${this.catch.block.name}, catch: ${this.catch.block.name},

@ -307,8 +307,8 @@ const attribute_lookup = {
'optgroup', 'optgroup',
'option', 'option',
'select', 'select',
'textarea', 'textarea'
], ]
}, },
formnovalidate: { property_name: 'formNoValidate', applies_to: ['button', 'input'] }, formnovalidate: { property_name: 'formNoValidate', applies_to: ['button', 'input'] },
hidden: {}, hidden: {},
@ -335,9 +335,9 @@ const attribute_lookup = {
'progress', 'progress',
'param', 'param',
'select', 'select',
'textarea', 'textarea'
], ]
}, }
}; };
Object.keys(attribute_lookup).forEach(name => { Object.keys(attribute_lookup).forEach(name => {

@ -302,7 +302,7 @@ function get_binding_group(renderer: Renderer, value: Binding, block: Block) {
}, },
is_context: contexts.length > 0, is_context: contexts.length > 0,
contexts, contexts,
index, index
}); });
} }
@ -355,7 +355,7 @@ function get_event_handler(
uses_context: binding.node.is_contextual || binding.node.expression.uses_context, // TODO this is messy uses_context: binding.node.is_contextual || binding.node.expression.uses_context, // TODO this is messy
mutation, mutation,
contextual_dependencies, contextual_dependencies,
lhs, lhs
}; };
} }

@ -132,7 +132,7 @@ const events = [
event_names: ['toggle'], event_names: ['toggle'],
filter: (node: Element, _name: string) => filter: (node: Element, _name: string) =>
node.name === 'details' node.name === 'details'
}, }
]; ];
export default class ElementWrapper extends Wrapper { export default class ElementWrapper extends Wrapper {
@ -725,6 +725,18 @@ export default class ElementWrapper extends Wrapper {
block.chunks.update.push(b` block.chunks.update.push(b`
if (${block.renderer.dirty(Array.from(dependencies))} && ${data}.multiple) @select_options(${this.var}, ${data}.value); if (${block.renderer.dirty(Array.from(dependencies))} && ${data}.multiple) @select_options(${this.var}, ${data}.value);
`); `);
} else if (this.node.name === 'input' && this.attributes.find(attr => attr.node.name === 'value')) {
const type = this.node.get_static_attribute_value('type');
if (type === null || type === "" || type === "text" || type === "email" || type === "password") {
block.chunks.mount.push(b`
${this.var}.value = ${data}.value;
`);
block.chunks.update.push(b`
if ('value' in ${data}) {
${this.var}.value = ${data}.value;
}
`);
}
} }
} }

@ -603,7 +603,7 @@ export default class IfBlockWrapper extends Wrapper {
// as -1 // as -1
operator: val.operator, operator: val.operator,
prefix: val.prefix, prefix: val.prefix,
argument: val.argument, argument: val.argument
}; };
} }
} }

@ -112,7 +112,7 @@ export default class InlineComponentWrapper extends Wrapper {
if (variable.reassigned || variable.export_name || variable.is_reactive_dependency) { if (variable.reassigned || variable.export_name || variable.is_reactive_dependency) {
this.renderer.component.warn(this.node, { this.renderer.component.warn(this.node, {
code: 'reactive-component', code: 'reactive-component',
message: `<${name}/> will not be reactive if ${name} changes. Use <svelte:component this={${name}}/> if you want this reactivity.`, message: `<${name}/> will not be reactive if ${name} changes. Use <svelte:component this={${name}}/> if you want this reactivity.`
}); });
} }
} }

@ -16,7 +16,7 @@ const associated_events = {
outerHeight: 'resize', outerHeight: 'resize',
scrollX: 'scroll', scrollX: 'scroll',
scrollY: 'scroll', scrollY: 'scroll'
}; };
const properties = { const properties = {
@ -29,7 +29,7 @@ const readonly = new Set([
'innerHeight', 'innerHeight',
'outerWidth', 'outerWidth',
'outerHeight', 'outerHeight',
'online', 'online'
]); ]);
export default class WindowWrapper extends Wrapper { export default class WindowWrapper extends Wrapper {

@ -34,13 +34,13 @@ export function get_slot_definition(block: Block, scope: TemplateScope, lets: Le
type: 'Property', type: 'Property',
kind: 'init', kind: 'init',
key: l.name, key: l.name,
value, value
}); });
}); });
const changes_input = { const changes_input = {
type: 'ObjectPattern', type: 'ObjectPattern',
properties, properties
}; };
const names: Set<string> = new Set(); const names: Set<string> = new Set();

@ -4,13 +4,13 @@ export function string_to_member_expression(name: string) {
const parts = name.split("."); const parts = name.split(".");
let node: MemberExpression | Identifier = { let node: MemberExpression | Identifier = {
type: "Identifier", type: "Identifier",
name: parts[0], name: parts[0]
}; };
for (let i = 1; i < parts.length; i++) { for (let i = 1; i < parts.length; i++) {
node = { node = {
type: "MemberExpression", type: "MemberExpression",
object: node, object: node,
property: { type: "Identifier", name: parts[i] }, property: { type: "Identifier", name: parts[i] }
} as MemberExpression; } as MemberExpression;
} }
return node; return node;

@ -16,7 +16,7 @@ const escaped = {
"'": '&#39;', "'": '&#39;',
'&': '&amp;', '&': '&amp;',
'<': '&lt;', '<': '&lt;',
'>': '&gt;', '>': '&gt;'
}; };
export function escape_html(html) { export function escape_html(html) {

@ -41,7 +41,7 @@ export class Parser {
start: null, start: null,
end: null, end: null,
type: 'Fragment', type: 'Fragment',
children: [], children: []
}; };
this.stack.push(this.html); this.stack.push(this.html);

@ -57,6 +57,6 @@ export default function read_script(parser: Parser, start: number, attributes: N
start, start,
end: parser.index, end: parser.index,
context: get_context(parser, attributes, start), context: get_context(parser, attributes, start),
content: ast, content: ast
}; };
} }

@ -14,7 +14,7 @@ export default function read_style(parser: Parser, start: number, attributes: No
try { try {
ast = parse(styles, { ast = parse(styles, {
positions: true, positions: true,
offset: content_start, offset: content_start
}); });
} catch (err) { } catch (err) {
if (err.name === 'CssSyntaxError') { if (err.name === 'CssSyntaxError') {

@ -134,9 +134,9 @@ export default function mustache(parser: Parser) {
type: 'IfBlock', type: 'IfBlock',
elseif: true, elseif: true,
expression, expression,
children: [], children: []
}, }
], ]
}; };
parser.stack.push(block.else.children[0]); parser.stack.push(block.else.children[0]);
@ -161,7 +161,7 @@ export default function mustache(parser: Parser) {
start: parser.index, start: parser.index,
end: null, end: null,
type: 'ElseBlock', type: 'ElseBlock',
children: [], children: []
}; };
parser.stack.push(block.else); parser.stack.push(block.else);
@ -260,14 +260,14 @@ export default function mustache(parser: Parser) {
type: 'CatchBlock', type: 'CatchBlock',
children: [], children: [],
skip: true skip: true
}, }
} : } :
{ {
start, start,
end: null, end: null,
type, type,
expression, expression,
children: [], children: []
}; };
parser.allow_whitespace(); parser.allow_whitespace();
@ -350,7 +350,7 @@ export default function mustache(parser: Parser) {
start, start,
end: parser.index, end: parser.index,
type: 'RawMustacheTag', type: 'RawMustacheTag',
expression, expression
}); });
} else if (parser.eat('@debug')) { } else if (parser.eat('@debug')) {
let identifiers; let identifiers;
@ -394,7 +394,7 @@ export default function mustache(parser: Parser) {
start, start,
end: parser.index, end: parser.index,
type: 'MustacheTag', type: 'MustacheTag',
expression, expression
}); });
} }
} }

@ -25,16 +25,16 @@ const specials = new Map([
'script', 'script',
{ {
read: read_script, read: read_script,
property: 'js', property: 'js'
}, }
], ],
[ [
'style', 'style',
{ {
read: read_style, read: read_style,
property: 'css', property: 'css'
}, }
], ]
]); ]);
const SELF = /^svelte:self(?=[\s/>])/; const SELF = /^svelte:self(?=[\s/>])/;
@ -63,7 +63,7 @@ export default function tag(parser: Parser) {
start, start,
end: parser.index, end: parser.index,
type: 'Comment', type: 'Comment',
data, data
}); });
return; return;
@ -116,7 +116,7 @@ export default function tag(parser: Parser) {
type, type,
name, name,
attributes: [], attributes: [],
children: [], children: []
}; };
parser.allow_whitespace(); parser.allow_whitespace();
@ -163,7 +163,7 @@ export default function tag(parser: Parser) {
parser.last_auto_closed_tag = { parser.last_auto_closed_tag = {
tag: parent.name, tag: parent.name,
reason: name, reason: name,
depth: parser.stack.length, depth: parser.stack.length
}; };
} }
@ -437,7 +437,7 @@ function read_attribute(parser: Parser, unique_names: Set<string>) {
end, end,
type: 'Attribute', type: 'Attribute',
name, name,
value, value
}; };
} }
@ -504,7 +504,7 @@ function read_sequence(parser: Parser, done: () => boolean): TemplateNode[] {
start: index, start: index,
end: parser.index, end: parser.index,
type: 'MustacheTag', type: 'MustacheTag',
expression, expression
}); });
current_chunk = { current_chunk = {

@ -19,7 +19,7 @@ export default function text(parser: Parser) {
end: parser.index, end: parser.index,
type: 'Text', type: 'Text',
raw: data, raw: data,
data: decode_character_references(data), data: decode_character_references(data)
}; };
parser.current().children.push(node); parser.current().children.push(node);

@ -2030,5 +2030,5 @@ export default {
sc: 8827, sc: 8827,
wp: 8472, wp: 8472,
wr: 8768, wr: 8768,
xi: 958, xi: 958
}; };

@ -32,7 +32,7 @@ const windows_1252 = [
339, 339,
157, 157,
382, 382,
376, 376
]; ];
const entity_pattern = new RegExp( const entity_pattern = new RegExp(
@ -124,7 +124,7 @@ const disallowed_contents = new Map([
'address article aside blockquote div dl fieldset footer form h1 h2 h3 h4 h5 h6 header hgroup hr main menu nav ol p pre section table ul'.split( 'address article aside blockquote div dl fieldset footer form h1 h2 h3 h4 h5 h6 header hgroup hr main menu nav ol p pre section table ul'.split(
' ' ' '
) )
), )
], ],
['rt', new Set(['rt', 'rp'])], ['rt', new Set(['rt', 'rp'])],
['rp', new Set(['rt', 'rp'])], ['rp', new Set(['rt', 'rp'])],
@ -135,7 +135,7 @@ const disallowed_contents = new Map([
['tfoot', new Set(['tbody'])], ['tfoot', new Set(['tbody'])],
['tr', new Set(['tr', 'tbody'])], ['tr', new Set(['tr', 'tbody'])],
['td', new Set(['td', 'th', 'tr'])], ['td', new Set(['td', 'th', 'tr'])],
['th', new Set(['td', 'th', 'tr'])], ['th', new Set(['td', 'th', 'tr'])]
]); ]);
// can this be a child of the parent element, or does it implicitly // can this be a child of the parent element, or does it implicitly

@ -49,7 +49,7 @@ async function replace_async(str: string, re: RegExp, func: (...any) => Promise<
({ ({
offset: args[args.length - 2], offset: args[args.length - 2],
length: args[0].length, length: args[0].length,
replacement: res, replacement: res
}) as Replacement }) as Replacement
) )
); );

@ -206,7 +206,7 @@ class FuzzySet {
match_score = matches[match_index]; match_score = matches[match_index];
results.push([ results.push([
match_score / (vector_normal * items[match_index][0]), match_score / (vector_normal * items[match_index][0]),
items[match_index][1], items[match_index][1]
]); ]);
} }
@ -218,7 +218,7 @@ class FuzzySet {
for (let i = 0; i < end_index; ++i) { for (let i = 0; i < end_index; ++i) {
new_results.push([ new_results.push([
_distance(results[i][1], normalized_value), _distance(results[i][1], normalized_value),
results[i][1], results[i][1]
]); ]);
} }
results = new_results; results = new_results;

@ -105,7 +105,7 @@ export const reserved = new Set([
'void', 'void',
'while', 'while',
'with', 'with',
'yield', 'yield'
]); ]);
const void_element_names = /^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/; const void_element_names = /^(?:area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/;

@ -17,7 +17,7 @@ export const valid_namespaces = [
svg, svg,
xlink, xlink,
xml, xml,
xmlns, xmlns
]; ];
export const namespaces: Record<string, string> = { html, mathml, svg, xlink, xml, xmlns }; export const namespaces: Record<string, string> = { html, mathml, svg, xlink, xml, xmlns };

@ -59,6 +59,9 @@ export function handle_promise(promise, info) {
update(info.then, 1, info.value, value); update(info.then, 1, info.value, value);
set_current_component(null); set_current_component(null);
}, error => { }, error => {
if (!info.hasCatch) {
throw error;
}
set_current_component(current_component); set_current_component(current_component);
update(info.catch, 2, info.error, error); update(info.catch, 2, info.error, error);
set_current_component(null); set_current_component(null);

@ -52,7 +52,7 @@ const subscriber_queue = [];
*/ */
export function readable<T>(value: T, start: StartStopNotifier<T>): Readable<T> { export function readable<T>(value: T, start: StartStopNotifier<T>): Readable<T> {
return { return {
subscribe: writable(value, start).subscribe, subscribe: writable(value, start).subscribe
}; };
} }
@ -184,7 +184,7 @@ export function derived<T>(stores: Stores, fn: Function, initial_value?: T): Rea
}, },
() => { () => {
pending |= (1 << i); pending |= (1 << i);
}), })
); );
inited = true; inited = true;

@ -12,7 +12,7 @@ export default {
13: .foocc {color: red;}`, 13: .foocc {color: red;}`,
start: { line: 11, column: 2, character: 206 }, start: { line: 11, column: 2, character: 206 },
end: { line: 11, column: 8, character: 212 }, end: { line: 11, column: 8, character: 212 },
pos: 206, pos: 206
}, },
{ {
code: 'css-unused-selector', code: 'css-unused-selector',
@ -26,7 +26,7 @@ export default {
14: .foodd {color: red;}`, 14: .foodd {color: red;}`,
start: { line: 12, column: 2, character: 229 }, start: { line: 12, column: 2, character: 229 },
end: { line: 12, column: 8, character: 235 }, end: { line: 12, column: 8, character: 235 },
pos: 229, pos: 229
}, },
{ {
code: 'css-unused-selector', code: 'css-unused-selector',
@ -40,7 +40,7 @@ export default {
16: .bb {color: red;}`, 16: .bb {color: red;}`,
start: { line: 14, column: 2, character: 275 }, start: { line: 14, column: 2, character: 275 },
end: { line: 14, column: 8, character: 281 }, end: { line: 14, column: 8, character: 281 },
pos: 275, pos: 275
}, },
{ {
code: 'css-unused-selector', code: 'css-unused-selector',
@ -54,7 +54,7 @@ export default {
22: .ddbar {color: red;}`, 22: .ddbar {color: red;}`,
start: { line: 20, column: 2, character: 401 }, start: { line: 20, column: 2, character: 401 },
end: { line: 20, column: 8, character: 407 }, end: { line: 20, column: 8, character: 407 },
pos: 401, pos: 401
}, },
{ {
code: 'css-unused-selector', code: 'css-unused-selector',
@ -68,7 +68,7 @@ export default {
23: .fooaabar {color: red;}`, 23: .fooaabar {color: red;}`,
start: { line: 21, column: 2, character: 424 }, start: { line: 21, column: 2, character: 424 },
end: { line: 21, column: 8, character: 430 }, end: { line: 21, column: 8, character: 430 },
pos: 424, pos: 424
}, },
{ {
code: 'css-unused-selector', code: 'css-unused-selector',
@ -82,7 +82,7 @@ export default {
24: .foobbbar {color: red;}`, 24: .foobbbar {color: red;}`,
start: { line: 22, column: 2, character: 447 }, start: { line: 22, column: 2, character: 447 },
end: { line: 22, column: 8, character: 453 }, end: { line: 22, column: 8, character: 453 },
pos: 447, pos: 447
}, },
{ {
code: 'css-unused-selector', code: 'css-unused-selector',
@ -96,7 +96,7 @@ export default {
25: .fooccbar {color: red;}`, 25: .fooccbar {color: red;}`,
start: { line: 23, column: 2, character: 470 }, start: { line: 23, column: 2, character: 470 },
end: { line: 23, column: 11, character: 479 }, end: { line: 23, column: 11, character: 479 },
pos: 470, pos: 470
}, },
{ {
code: 'css-unused-selector', code: 'css-unused-selector',
@ -110,7 +110,7 @@ export default {
26: .fooddbar {color: red;}`, 26: .fooddbar {color: red;}`,
start: { line: 24, column: 2, character: 496 }, start: { line: 24, column: 2, character: 496 },
end: { line: 24, column: 11, character: 505 }, end: { line: 24, column: 11, character: 505 },
pos: 496, pos: 496
}, },
{ {
code: 'css-unused-selector', code: 'css-unused-selector',
@ -124,7 +124,7 @@ export default {
27: .baz {color: red;}`, 27: .baz {color: red;}`,
start: { line: 25, column: 2, character: 522 }, start: { line: 25, column: 2, character: 522 },
end: { line: 25, column: 11, character: 531 }, end: { line: 25, column: 11, character: 531 },
pos: 522, pos: 522
}, },
{ {
code: 'css-unused-selector', code: 'css-unused-selector',
@ -137,7 +137,7 @@ export default {
29: </style>`, 29: </style>`,
start: { line: 28, column: 2, character: 595 }, start: { line: 28, column: 2, character: 595 },
end: { line: 28, column: 9, character: 602 }, end: { line: 28, column: 9, character: 602 },
pos: 595, pos: 595
}, }
], ]
}; };

@ -1,3 +1,3 @@
export default { export default {
warnings: [], warnings: []
}; };

@ -5,7 +5,7 @@ export default {
end: { end: {
character: 205, character: 205,
column: 9, column: 9,
line: 14, line: 14
}, },
frame: ` frame: `
12: .thing.active {color: blue;} 12: .thing.active {color: blue;}
@ -18,8 +18,8 @@ export default {
start: { start: {
character: 198, character: 198,
column: 2, column: 2,
line: 14, line: 14
}, }
}, }
], ]
}; };

@ -12,7 +12,7 @@ export default {
17: .unused {color: blue;}`, 17: .unused {color: blue;}`,
start: { line: 15, column: 2, character: 261 }, start: { line: 15, column: 2, character: 261 },
end: { line: 15, column: 15, character: 274 }, end: { line: 15, column: 15, character: 274 },
pos: 261, pos: 261
}, },
{ {
code: 'css-unused-selector', code: 'css-unused-selector',
@ -25,7 +25,7 @@ export default {
18: </style>`, 18: </style>`,
start: { line: 17, column: 2, character: 295 }, start: { line: 17, column: 2, character: 295 },
end: { line: 17, column: 9, character: 302 }, end: { line: 17, column: 9, character: 302 },
pos: 295, pos: 295
}, }
], ]
}; };

@ -153,6 +153,7 @@ export function normalizeHtml(window, html) {
export function setupHtmlEqual() { export function setupHtmlEqual() {
const window = env(); const window = env();
// eslint-disable-next-line no-import-assign
assert.htmlEqual = (actual, expected, message) => { assert.htmlEqual = (actual, expected, message) => {
assert.deepEqual( assert.deepEqual(
normalizeHtml(window, actual), normalizeHtml(window, actual),

@ -7,7 +7,7 @@ export default {
return { return {
nullText, nullText,
undefinedText, undefinedText
}; };
}, },
@ -17,5 +17,5 @@ export default {
assert.equal(nullText, snapshot.nullText); assert.equal(nullText, snapshot.nullText);
assert.equal(undefinedText, snapshot.undefinedText); assert.equal(undefinedText, snapshot.undefinedText);
}, }
}; };

@ -3,7 +3,7 @@ export default {
const h1 = target.querySelector('h1'); const h1 = target.querySelector('h1');
return { return {
h1, h1
}; };
}, },

@ -1,6 +1,6 @@
export default { export default {
options: { options: {
dev: true, dev: true,
loopGuardTimeout: 100, loopGuardTimeout: 100
}, }
}; };

@ -2,7 +2,7 @@ export default {
preprocess: [ preprocess: [
{ {
script: ({ content }) => ({ code: content.replace(/one/g, 'two') }), script: ({ content }) => ({ code: content.replace(/one/g, 'two') }),
style: ({ content }) => ({ code: content.replace(/one/g, 'three') }), style: ({ content }) => ({ code: content.replace(/one/g, 'three') })
}, }
], ]
}; };

@ -11,7 +11,7 @@ export default {
<div d="4" e="5" foo="1"></div> <div d="4" e="5" foo="1"></div>
<button></button><button></button><button></button><button></button> <button></button><button></button><button></button><button></button>
`, `,
async test({ assert, target, window, }) { async test({ assert, target, window }) {
const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button'); const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click'); const clickEvent = new window.MouseEvent('click');

@ -13,7 +13,7 @@ export default {
<button></button><button></button><button></button><button></button> <button></button><button></button><button></button><button></button>
`, `,
async test({ assert, target, window, }) { async test({ assert, target, window }) {
const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button'); const [btn1, btn2, btn3, btn4] = target.querySelectorAll('button');
const clickEvent = new window.MouseEvent('click'); const clickEvent = new window.MouseEvent('click');

@ -18,5 +18,5 @@ export default {
input.dispatchEvent(event); input.dispatchEvent(event);
assert.ok(blurred); assert.ok(blurred);
}, }
}; };

@ -1,7 +1,7 @@
export default { export default {
props: { props: {
target: 'World!', target: 'World!',
display: true, display: true
}, },
html: ` html: `
@ -16,5 +16,5 @@ export default {
assert.htmlEqual(target.innerHTML, ` assert.htmlEqual(target.innerHTML, `
<h1>Hello World!</h1> <h1>Hello World!</h1>
`); `);
}, }
}; };

@ -7,5 +7,5 @@ export default {
await button.dispatchEvent(click); await button.dispatchEvent(click);
await Promise.resolve(); await Promise.resolve();
assert.htmlEqual(target.innerHTML, `<button>2</button>`); assert.htmlEqual(target.innerHTML, `<button>2</button>`);
}, }
}; };

@ -1,7 +1,7 @@
const value = []; const value = [];
export default { export default {
props: { props: {
value, value
}, },
async test({ assert, component, target, window }) { async test({ assert, component, target, window }) {
@ -32,7 +32,7 @@ export default {
'15', '15',
'16', '16',
'17', '17',
'18', '18'
]); ]);
}, }
}; };

@ -33,5 +33,5 @@ export default {
<input> <input>
<p>HE</p> <p>HE</p>
`); `);
}, }
}; };

@ -3,5 +3,5 @@ export default {
test({ assert, component, target }) { test({ assert, component, target }) {
const textarea = target.querySelector('textarea'); const textarea = target.querySelector('textarea');
assert.ok(textarea.readOnly === false); assert.ok(textarea.readOnly === false);
}, }
}; };

@ -3,5 +3,5 @@ export default {
test({ assert, component, target }) { test({ assert, component, target }) {
const textarea = target.querySelector('textarea'); const textarea = target.querySelector('textarea');
assert.ok(textarea.readOnly); assert.ok(textarea.readOnly);
}, }
}; };

@ -1,3 +1,3 @@
export default { export default {
html: '<div data-potato=""></div>', html: '<div data-potato=""></div>'
}; };

@ -1,5 +1,5 @@
export default { export default {
html: ` html: `
<div><div title='foo'>bar</div></div> <div><div title='foo'>bar</div></div>
`, `
}; };

@ -1,3 +1,3 @@
export default { export default {
html: `<div class="false"></div>`, html: `<div class="false"></div>`
}; };

@ -1,7 +1,7 @@
export default { export default {
props: { props: {
testName1: "test1", testName1: "test1",
testName2: "test2", testName2: "test2"
}, },
html: `<div class="test1test2"></div>`, html: `<div class="test1test2"></div>`,

@ -1,7 +1,7 @@
export default { export default {
props: { props: {
testName1: "test1", testName1: "test1",
testName2: "test2", testName2: "test2"
}, },
html: `<div class="test1test2 svelte-x1o6ra"></div>`, html: `<div class="test1test2 svelte-x1o6ra"></div>`,

@ -1,7 +1,7 @@
export default { export default {
props: { props: {
testName1: "test1", testName1: "test1",
testName2: "test2", testName2: "test2"
}, },
html: `<div class="test1test2"></div>`, html: `<div class="test1test2"></div>`,

@ -1,7 +1,7 @@
export default { export default {
props: { props: {
testName1: "test1", testName1: "test1",
testName2: "test2", testName2: "test2"
}, },
html: `<div class="test1test2 svelte-x1o6ra"></div>`, html: `<div class="test1test2 svelte-x1o6ra"></div>`,

@ -1,3 +1,3 @@
export default { export default {
html: `<div></div>`, html: `<div></div>`
}; };

@ -2,7 +2,7 @@ export default {
skip_if_ssr: true, skip_if_ssr: true,
props: { props: {
foo: false, foo: false
}, },
test({ assert, component, target }) { test({ assert, component, target }) {
@ -15,5 +15,5 @@ export default {
assert.ok(!inputs[0].checked); assert.ok(!inputs[0].checked);
assert.ok(inputs[1].checked); assert.ok(inputs[1].checked);
}, }
}; };

@ -1,3 +1,3 @@
export default { export default {
html: `<div></div>`, html: `<div></div>`
}; };

@ -1,7 +1,7 @@
export default { export default {
props: { props: {
thePromise: new Promise((_) => {}), thePromise: new Promise((_) => {}),
count: 0, count: 0
}, },
html: ` html: `
@ -60,5 +60,5 @@ export default {
</div> </div>
` `
); );
}, }
}; };

@ -1,7 +1,7 @@
export default { export default {
props: { props: {
thePromise: new Promise((_) => {}), thePromise: new Promise((_) => {}),
count: 0, count: 0
}, },
html: ` html: `
@ -56,5 +56,5 @@ export default {
</div> </div>
` `
); );
}, }
}; };

@ -0,0 +1,44 @@
let fulfil;
let promise = new Promise(f => {
fulfil = f;
});
export default {
props: {
promise
},
html: `
<p>loading...</p>
`,
test({ assert, component, target }) {
fulfil(42);
return promise
.then(() => {
assert.htmlEqual(target.innerHTML, `
<p>loaded</p>
`);
let reject;
promise = new Promise((f, r) => {
reject = r;
});
component.promise = promise;
assert.htmlEqual(target.innerHTML, `
<p>loading...</p>
`);
reject(new Error('this error should be thrown'));
return promise;
})
.catch((err) => {
assert.equal(err.message, 'this error should be thrown');
});
}
};

@ -0,0 +1,9 @@
<script>
export let promise;
</script>
{#await promise}
<p>loading...</p>
{:then value}
<p>loaded</p>
{/await}

@ -36,5 +36,5 @@ export default {
<editor contenteditable="true">good<span>bye</span></editor> <editor contenteditable="true">good<span>bye</span></editor>
<p>hello good<span>bye</span></p> <p>hello good<span>bye</span></p>
`); `);
}, }
}; };

@ -1,6 +1,6 @@
export default { export default {
props: { props: {
name: '<b>world</b>', name: '<b>world</b>'
}, },
html: ` html: `
@ -34,5 +34,5 @@ export default {
<editor contenteditable="true">good<span>bye</span></editor> <editor contenteditable="true">good<span>bye</span></editor>
<p>hello good<span>bye</span></p> <p>hello good<span>bye</span></p>
`); `);
}, }
}; };

@ -30,5 +30,5 @@ export default {
<editor contenteditable="true">goodbye</editor> <editor contenteditable="true">goodbye</editor>
<p>hello goodbye</p> <p>hello goodbye</p>
`); `);
}, }
}; };

@ -1,6 +1,6 @@
export default { export default {
props: { props: {
name: 'world', name: 'world'
}, },
html: ` html: `
@ -28,5 +28,5 @@ export default {
<editor contenteditable="true">goodbye</editor> <editor contenteditable="true">goodbye</editor>
<p>hello goodbye</p> <p>hello goodbye</p>
`); `);
}, }
}; };

@ -2,7 +2,7 @@ export default {
skip_if_ssr: true, skip_if_ssr: true,
props: { props: {
indeterminate: true, indeterminate: true
}, },
html: ` html: `
@ -38,5 +38,5 @@ export default {
<p>checked? true</p> <p>checked? true</p>
<p>indeterminate? true</p> <p>indeterminate? true</p>
`); `);
}, }
}; };

@ -3,13 +3,13 @@ export default {
cats: [ cats: [
{ {
name: "cat 0", name: "cat 0",
checked: false, checked: false
}, },
{ {
name: "cat 1", name: "cat 1",
checked: false, checked: false
}, }
], ]
}, },
html: ` html: `
@ -22,7 +22,7 @@ export default {
const newCats = cats.slice(); const newCats = cats.slice();
newCats.push({ newCats.push({
name: "cat " + cats.length, name: "cat " + cats.length,
checked: false, checked: false
}); });
component.cats = newCats; component.cats = newCats;

@ -77,5 +77,5 @@ export default {
assert.equal(inputs[5].checked, false); assert.equal(inputs[5].checked, false);
assert.equal(inputs[6].checked, false); assert.equal(inputs[6].checked, false);
assert.equal(inputs[7].checked, true); assert.equal(inputs[7].checked, true);
}, }
}; };

@ -7,13 +7,13 @@ const values = [
const selected_array = [ const selected_array = [
[values[1]], [values[1]],
[], [],
[values[2]], [values[2]]
]; ];
export default { export default {
props: { props: {
values, values,
selected_array, selected_array
}, },
html: ` html: `

@ -7,13 +7,13 @@ const values = [
const selected_array = [ const selected_array = [
[values[1]], [values[1]],
[], [],
[values[2]], [values[2]]
]; ];
export default { export default {
props: { props: {
values, values,
selected_array, selected_array
}, },
html: ` html: `

@ -27,5 +27,5 @@ export default {
component.value = 1; component.value = 1;
assert.equal(component.value, 1); assert.equal(component.value, 1);
assert.equal(input.value, "1"); assert.equal(input.value, "1");
}, }
}; };

@ -1,6 +1,6 @@
export default { export default {
props: { props: {
count: 42, count: 42
}, },
html: ` html: `
@ -44,5 +44,5 @@ export default {
<input type='number'> <input type='number'>
<p>undefined undefined</p> <p>undefined undefined</p>
`); `);
}, }
}; };

@ -29,5 +29,5 @@ export default {
<input type=range min=0 max=20> <input type=range min=0 max=20>
<p>20 of 20</p> <p>20 of 20</p>
`); `);
}, }
}; };

@ -1,6 +1,6 @@
export default { export default {
props: { props: {
count: 42, count: 42
}, },
html: ` html: `
@ -34,5 +34,5 @@ export default {
<input type='range'> <input type='range'>
<p>number 44</p> <p>number 44</p>
`); `);
}, }
}; };

@ -1,6 +1,6 @@
export default { export default {
props: { props: {
count: 42, count: 42
}, },
html: ` html: `
@ -34,5 +34,5 @@ export default {
<input type='range'> <input type='range'>
<p>number 44</p> <p>number 44</p>
`); `);
}, }
}; };

@ -1,7 +1,7 @@
export default { export default {
props: { props: {
foo: 'a', foo: 'a',
items: ['x'], items: ['x']
}, },
html: ` html: `
@ -32,5 +32,5 @@ export default {
<div><input><p>b</p></div> <div><input><p>b</p></div>
<div><input><p>y</p></div> <div><input><p>y</p></div>
`); `);
}, }
}; };

@ -121,5 +121,5 @@ export default {
<p>done:one / done:two / remaining:four</p> <p>done:one / done:two / remaining:four</p>
`); `);
}, }
}; };

@ -1,6 +1,6 @@
export default { export default {
props: { props: {
items: ['one', 'two', 'three'], items: ['one', 'two', 'three']
}, },
html: ` html: `
@ -65,5 +65,5 @@ export default {
<input><p>five</p> <input><p>five</p>
</div> </div>
`); `);
}, }
}; };

@ -1,8 +1,8 @@
export default { export default {
props: { props: {
component: { component: {
name: 'world', name: 'world'
}, }
}, },
html: ` html: `
@ -36,5 +36,5 @@ export default {
<h1>Hello goodbye!</h1> <h1>Hello goodbye!</h1>
<input> <input>
`); `);
}, }
}; };

@ -4,8 +4,8 @@ export default {
obj: { obj: {
foo: 'a', foo: 'a',
bar: 'b', bar: 'b',
baz: 'c', baz: 'c'
}, }
}, },
html: ` html: `
@ -56,5 +56,5 @@ export default {
<input> <input>
<pre>{"foo":"d","bar":"e","baz":"f"}</pre> <pre>{"foo":"d","bar":"e","baz":"f"}</pre>
`); `);
}, }
}; };

@ -2,8 +2,8 @@ export default {
props: { props: {
prop: 'name', prop: 'name',
user: { user: {
name: 'alice', name: 'alice'
}, }
}, },
html: ` html: `
@ -40,5 +40,5 @@ export default {
<input> <input>
<p>hello carol</p> <p>hello carol</p>
`); `);
}, }
}; };

@ -5,9 +5,9 @@ export default {
{ {
foo: 'a', foo: 'a',
bar: 'b', bar: 'b',
baz: 'c', baz: 'c'
}, }
], ]
}, },
html: ` html: `
@ -58,5 +58,5 @@ export default {
<input> <input>
<pre>{"foo":"d","bar":"e","baz":"f"}</pre> <pre>{"foo":"d","bar":"e","baz":"f"}</pre>
`); `);
}, }
}; };

@ -3,8 +3,8 @@ export default {
items: [ items: [
{ description: 'one' }, { description: 'one' },
{ description: 'two' }, { description: 'two' },
{ description: 'three' }, { description: 'three' }
], ]
}, },
html: ` html: `
@ -45,5 +45,5 @@ export default {
<div><input><p>four</p></div> <div><input><p>four</p></div>
<div><input><p>five</p></div> <div><input><p>five</p></div>
`); `);
}, }
}; };

@ -1,8 +1,8 @@
export default { export default {
props: { props: {
user: { user: {
name: 'alice', name: 'alice'
}, }
}, },
html: ` html: `
@ -39,5 +39,5 @@ export default {
<input> <input>
<p>hello carol</p> <p>hello carol</p>
`); `);
}, }
}; };

@ -26,5 +26,5 @@ export default {
component.x = undefined; component.x = undefined;
assert.equal(input.value, ''); assert.equal(input.value, '');
}, }
}; };

@ -1,6 +1,6 @@
export default { export default {
props: { props: {
name: 'world', name: 'world'
}, },
html: ` html: `
@ -33,5 +33,5 @@ export default {
<input> <input>
<p>hello goodbye</p> <p>hello goodbye</p>
`); `);
}, }
}; };

@ -24,7 +24,7 @@ export default {
`, `,
props: { props: {
selected: 'b', selected: 'b'
}, },
test({ assert, component, target }) { test({ assert, component, target }) {
@ -33,5 +33,5 @@ export default {
assert.equal(select.value, 'b'); assert.equal(select.value, 'b');
assert.ok(options[1].selected); assert.ok(options[1].selected);
}, }
}; };

@ -45,5 +45,5 @@ export default {
</optgroup> </optgroup>
</select> </select>
`); `);
}, }
}; };

@ -24,7 +24,7 @@ export default {
`, `,
props: { props: {
selected: 'one', selected: 'one'
}, },
async test({ assert, component, target, window }) { async test({ assert, component, target, window }) {
@ -53,5 +53,5 @@ export default {
`); `);
component.selected = 'three'; component.selected = 'three';
}, }
}; };

@ -37,5 +37,5 @@ export default {
assert.deepEqual(names, ['world', 'everybody', 'goodbye']); assert.deepEqual(names, ['world', 'everybody', 'goodbye']);
unsubscribe(); unsubscribe();
}, }
}; };

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

Loading…
Cancel
Save