Merge branch 'master' into bugfix/2446_apply_directives_in_order

pull/2737/head
Colin Casey 6 years ago committed by GitHub
commit 95c7e4c320
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -38,7 +38,6 @@
"sourceType": "module" "sourceType": "module"
}, },
"settings": { "settings": {
"import/core-modules": ["svelte"], "import/core-modules": ["svelte"]
"svelte3/extensions": ["html"]
} }
} }

@ -1,5 +1,5 @@
[ignore] [ignore]
<PROJECT_ROOT>/dist/.* <PROJECT_ROOT>/types/.*
[include] [include]

2
.gitignore vendored

@ -21,7 +21,7 @@ node_modules
/test/sourcemaps/samples/*/output.css.map /test/sourcemaps/samples/*/output.css.map
/yarn-error.log /yarn-error.log
_actual*.* _actual*.*
/dist /types
/site/cypress/screenshots/ /site/cypress/screenshots/
/site/__sapper__/ /site/__sapper__/

@ -1,5 +1,15 @@
# Svelte changelog # Svelte changelog
## 3.4.4
* Publish type declaration files ([#2874](https://github.com/sveltejs/svelte/issues/2874))
* Don't trigger updates for unreferenced values ([#2865](https://github.com/sveltejs/svelte/pull/2865))
* Omit readonly bindings from SSR output ([#2339](https://github.com/sveltejs/svelte/issues/2339))
* Prevent outdated animation CSS ([#2871](https://github.com/sveltejs/svelte/issues/2871))
* Repair dynamic `{@html ...}` in head ([#2880](https://github.com/sveltejs/svelte/pull/2880))
* Don't create unknown prop warnings for internal props, or if component has `$$props` ([#2881](https://github.com/sveltejs/svelte/pull/2881))
## 3.4.3 ## 3.4.3
* Add type declaration files for everything ([#2842](https://github.com/sveltejs/svelte/pull/2842)) * Add type declaration files for everything ([#2842](https://github.com/sveltejs/svelte/pull/2842))

2
animate.d.ts vendored

@ -1 +1 @@
export * from './dist/animate'; export * from './types/animate';

2
compiler.d.ts vendored

@ -1 +1 @@
export * from './dist/compiler'; export * from './types/compiler';

2
easing.d.ts vendored

@ -1 +1 @@
export * from './dist/easing'; export * from './types/easing';

2
index.d.ts vendored

@ -1 +1 @@
export * from './dist/index'; export * from './types/index';

2
internal.d.ts vendored

@ -1 +1 @@
export * from './dist/internal'; export * from './types/internal';

2
motion.d.ts vendored

@ -1 +1 @@
export * from './dist/motion'; export * from './types/motion';

819
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,10 +1,11 @@
{ {
"name": "svelte", "name": "svelte",
"version": "3.4.3", "version": "3.4.4",
"description": "Cybernetically enhanced web apps", "description": "Cybernetically enhanced web apps",
"module": "index.mjs", "module": "index.mjs",
"main": "index", "main": "index",
"files": [ "files": [
"types",
"compiler.js", "compiler.js",
"register.js", "register.js",
"index.*", "index.*",
@ -25,13 +26,12 @@
"coverage": "c8 report --reporter=text-lcov > coverage.lcov && c8 report --reporter=html", "coverage": "c8 report --reporter=text-lcov > coverage.lcov && c8 report --reporter=html",
"codecov": "codecov", "codecov": "codecov",
"precodecov": "npm run coverage", "precodecov": "npm run coverage",
"lint": "eslint src test/*.js",
"build": "rollup -c", "build": "rollup -c",
"prepare": "npm run build && npm run tsd", "prepare": "npm run build && npm run tsd",
"dev": "rollup -cw", "dev": "rollup -cw",
"pretest": "npm run build", "pretest": "npm run build",
"posttest": "agadoo internal.mjs", "posttest": "agadoo internal.mjs",
"prepublishOnly": "export PUBLISH=true && npm run lint && npm test", "prepublishOnly": "export PUBLISH=true && npm test",
"tsd": "tsc -p . --emitDeclarationOnly", "tsd": "tsc -p . --emitDeclarationOnly",
"typecheck": "tsc -p . --noEmit" "typecheck": "tsc -p . --noEmit"
}, },
@ -61,10 +61,7 @@
"c8": "^3.4.0", "c8": "^3.4.0",
"codecov": "^3.0.0", "codecov": "^3.0.0",
"css-tree": "1.0.0-alpha22", "css-tree": "1.0.0-alpha22",
"eslint": "^5.3.0", "estree-walker": "^0.6.1",
"eslint-plugin-html": "^5.0.0",
"eslint-plugin-import": "^2.11.0",
"estree-walker": "^0.6.0",
"is-reference": "^1.1.1", "is-reference": "^1.1.1",
"jsdom": "^12.2.0", "jsdom": "^12.2.0",
"kleur": "^3.0.0", "kleur": "^3.0.0",

@ -789,6 +789,10 @@ export default class Component {
return `${name.slice(1)}.set(${name})` return `${name.slice(1)}.set(${name})`
} }
if (variable && !variable.referenced && !variable.is_reactive_dependency && !variable.export_name && !name.startsWith('$$')) {
return value || name;
}
if (value) { if (value) {
return `$$invalidate('${name}', ${value})`; return `$$invalidate('${name}', ${value})`;
} }
@ -1120,8 +1124,9 @@ export default class Component {
if (!assignee_nodes.has(identifier)) { if (!assignee_nodes.has(identifier)) {
const { name } = identifier; const { name } = identifier;
const owner = scope.find_owner(name); const owner = scope.find_owner(name);
const component_var = component.var_lookup.get(name); const variable = component.var_lookup.get(name);
const is_writable_or_mutated = component_var && (component_var.writable || component_var.mutated); if (variable) variable.is_reactive_dependency = true;
const is_writable_or_mutated = variable && (variable.writable || variable.mutated);
if ( if (
(!owner || owner === component.instance_scope) && (!owner || owner === component.instance_scope) &&
(name[0] === '$' || is_writable_or_mutated) (name[0] === '$' || is_writable_or_mutated)

@ -3,6 +3,15 @@ import get_object from '../utils/get_object';
import Expression from './shared/Expression'; import Expression from './shared/Expression';
import Component from '../Component'; import Component from '../Component';
import TemplateScope from './shared/TemplateScope'; import TemplateScope from './shared/TemplateScope';
import {dimensions} from "../../utils/patterns";
// TODO this should live in a specific binding
const read_only_media_attributes = new Set([
'duration',
'buffered',
'seekable',
'played'
]);
export default class Binding extends Node { export default class Binding extends Node {
type: 'Binding'; type: 'Binding';
@ -11,6 +20,7 @@ export default class Binding extends Node {
is_contextual: boolean; is_contextual: boolean;
obj: string; obj: string;
prop: string; prop: string;
is_readonly: boolean;
constructor(component: Component, parent, scope: TemplateScope, info) { constructor(component: Component, parent, scope: TemplateScope, info) {
super(component, parent, scope, info); super(component, parent, scope, info);
@ -64,5 +74,17 @@ export default class Binding extends Node {
this.obj = obj; this.obj = obj;
this.prop = prop; this.prop = prop;
const type = parent.get_static_attribute_value('type');
this.is_readonly = (
dimensions.test(this.name) ||
(parent.is_media_node && parent.is_media_node() && read_only_media_attributes.has(this.name)) ||
(parent.name === 'input' && type === 'file') // TODO others?
);
}
is_readonly_media_attribute() {
return read_only_media_attributes.has(this.name);
} }
} }

@ -47,7 +47,7 @@ export default class Node {
} }
get_static_attribute_value(name: string) { get_static_attribute_value(name: string) {
const attribute = this.attributes.find( const attribute = this.attributes && this.attributes.find(
(attr: Attribute) => attr.type === 'Attribute' && attr.name.toLowerCase() === name (attr: Attribute) => attr.type === 'Attribute' && attr.name.toLowerCase() === name
); );

@ -164,7 +164,7 @@ export default class Block {
if (parent_node) { if (parent_node) {
this.builders.mount.add_line(`@append(${parent_node}, ${name});`); this.builders.mount.add_line(`@append(${parent_node}, ${name});`);
if (parent_node === 'document.head') this.builders.destroy.add_line(`@detach(${name});`); if (parent_node === 'document.head' && !no_detach) this.builders.destroy.add_line(`@detach(${name});`);
} else { } else {
this.builders.mount.add_line(`@insert(#target, ${name}, anchor);`); this.builders.mount.add_line(`@insert(#target, ${name}, anchor);`);
if (!no_detach) this.builders.destroy.add_conditional('detaching', `@detach(${name});`); if (!no_detach) this.builders.destroy.add_conditional('detaching', `@detach(${name});`);

@ -203,8 +203,10 @@ export default function dom(
if (variable && (variable.hoistable || variable.global || variable.module)) return; if (variable && (variable.hoistable || variable.global || variable.module)) return;
if (single && !(variable.subscribable && variable.reassigned)) { if (single && !(variable.subscribable && variable.reassigned)) {
code.prependRight(node.start, `$$invalidate('${name}', `); if (variable.referenced || variable.is_reactive_dependency || variable.export_name) {
code.appendLeft(node.end, `)`); code.prependRight(node.start, `$$invalidate('${name}', `);
code.appendLeft(node.end, `)`);
}
} else { } else {
pending_assignments.add(name); pending_assignments.add(name);
} }
@ -395,11 +397,11 @@ export default function dom(
}); });
let unknown_props_check; let unknown_props_check;
if (component.compile_options.dev && writable_props.length) { if (component.compile_options.dev && !component.var_lookup.has('$$props') && writable_props.length) {
unknown_props_check = deindent` unknown_props_check = deindent`
const writable_props = [${writable_props.map(prop => `'${prop.export_name}'`).join(', ')}]; const writable_props = [${writable_props.map(prop => `'${prop.export_name}'`).join(', ')}];
Object.keys($$props).forEach(key => { Object.keys($$props).forEach(key => {
if (!writable_props.includes(key)) console.warn(\`<${component.tag}> was created with unknown prop '\${key}'\`); if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(\`<${component.tag}> was created with unknown prop '\${key}'\`);
}); });
`; `;
} }

@ -9,14 +9,6 @@ import flatten_reference from '../../../utils/flatten_reference';
import EachBlock from '../../../nodes/EachBlock'; import EachBlock from '../../../nodes/EachBlock';
import { Node as INode } from '../../../../interfaces'; import { Node as INode } from '../../../../interfaces';
// TODO this should live in a specific binding
const read_only_media_attributes = new Set([
'duration',
'buffered',
'seekable',
'played'
]);
function get_tail(node: INode) { function get_tail(node: INode) {
const end = node.end; const end = node.end;
while (node.type === 'MemberExpression') node = node.object; while (node.type === 'MemberExpression') node = node.object;
@ -74,13 +66,7 @@ export default class BindingWrapper {
this.snippet = this.node.expression.render(block); this.snippet = this.node.expression.render(block);
const type = parent.node.get_static_attribute_value('type'); this.is_readonly = this.node.is_readonly;
this.is_readonly = (
dimensions.test(this.node.name) ||
(parent.node.is_media_node() && read_only_media_attributes.has(this.node.name)) ||
(parent.node.name === 'input' && type === 'file') // TODO others?
);
this.needs_lock = this.node.name === 'currentTime'; // TODO others? this.needs_lock = this.node.name === 'currentTime'; // TODO others?
} }
@ -101,7 +87,7 @@ export default class BindingWrapper {
} }
is_readonly_media_attribute() { is_readonly_media_attribute() {
return read_only_media_attributes.has(this.node.name); return this.node.is_readonly_media_attribute()
} }
render(block: Block, lock: string) { render(block: Block, lock: string) {

@ -30,6 +30,6 @@ export default class HeadWrapper extends Wrapper {
} }
render(block: Block, parent_node: string, parent_nodes: string) { render(block: Block, parent_node: string, parent_nodes: string) {
this.fragment.render(block, 'document.head', null); this.fragment.render(block, 'document.head', 'nodes');
} }
} }

@ -154,16 +154,18 @@ export default class IfBlockWrapper extends Wrapper {
const vars = { name, anchor, if_name, has_else, has_transitions }; const vars = { name, anchor, if_name, has_else, has_transitions };
const detaching = (parent_node && parent_node !== 'document.head') ? '' : 'detaching';
if (this.node.else) { if (this.node.else) {
if (has_outros) { if (has_outros) {
this.render_compound_with_outros(block, parent_node, parent_nodes, dynamic, vars); this.render_compound_with_outros(block, parent_node, parent_nodes, dynamic, vars, detaching);
block.builders.outro.add_line(`if (${name}) ${name}.o();`); block.builders.outro.add_line(`if (${name}) ${name}.o();`);
} else { } else {
this.render_compound(block, parent_node, parent_nodes, dynamic, vars); this.render_compound(block, parent_node, parent_nodes, dynamic, vars, detaching);
} }
} else { } else {
this.render_simple(block, parent_node, parent_nodes, dynamic, vars); this.render_simple(block, parent_node, parent_nodes, dynamic, vars, detaching);
if (has_outros) { if (has_outros) {
block.builders.outro.add_line(`if (${name}) ${name}.o();`); block.builders.outro.add_line(`if (${name}) ${name}.o();`);
@ -201,7 +203,8 @@ export default class IfBlockWrapper extends Wrapper {
parent_node: string, parent_node: string,
parent_nodes: string, parent_nodes: string,
dynamic, dynamic,
{ name, anchor, has_else, if_name, has_transitions } { name, anchor, has_else, if_name, has_transitions },
detaching
) { ) {
const select_block_type = this.renderer.component.get_unique_name(`select_block_type`); const select_block_type = this.renderer.component.get_unique_name(`select_block_type`);
const current_block_type = block.get_unique_name(`current_block_type`); const current_block_type = block.get_unique_name(`current_block_type`);
@ -254,7 +257,7 @@ export default class IfBlockWrapper extends Wrapper {
`); `);
} }
block.builders.destroy.add_line(`${if_name}${name}.d(${parent_node ? '' : 'detaching'});`); block.builders.destroy.add_line(`${if_name}${name}.d(${detaching});`);
} }
// if any of the siblings have outros, we need to keep references to the blocks // if any of the siblings have outros, we need to keep references to the blocks
@ -264,7 +267,8 @@ export default class IfBlockWrapper extends Wrapper {
parent_node: string, parent_node: string,
parent_nodes: string, parent_nodes: string,
dynamic, dynamic,
{ name, anchor, has_else, has_transitions } { name, anchor, has_else, has_transitions },
detaching
) { ) {
const select_block_type = this.renderer.component.get_unique_name(`select_block_type`); const select_block_type = this.renderer.component.get_unique_name(`select_block_type`);
const current_block_type_index = block.get_unique_name(`current_block_type_index`); const current_block_type_index = block.get_unique_name(`current_block_type_index`);
@ -375,7 +379,7 @@ export default class IfBlockWrapper extends Wrapper {
} }
block.builders.destroy.add_line(deindent` block.builders.destroy.add_line(deindent`
${if_current_block_type_index}${if_blocks}[${current_block_type_index}].d(${parent_node ? '' : 'detaching'}); ${if_current_block_type_index}${if_blocks}[${current_block_type_index}].d(${detaching});
`); `);
} }
@ -384,7 +388,8 @@ export default class IfBlockWrapper extends Wrapper {
parent_node: string, parent_node: string,
parent_nodes: string, parent_nodes: string,
dynamic, dynamic,
{ name, anchor, if_name, has_transitions } { name, anchor, if_name, has_transitions },
detaching
) { ) {
const branch = this.branches[0]; const branch = this.branches[0];
@ -450,6 +455,6 @@ export default class IfBlockWrapper extends Wrapper {
} }
`); `);
block.builders.destroy.add_line(`${if_name}${name}.d(${parent_node ? '' : 'detaching'});`); block.builders.destroy.add_line(`${if_name}${name}.d(${detaching});`);
} }
} }

@ -22,9 +22,18 @@ export default class RawMustacheTagWrapper extends Tag {
render(block: Block, parent_node: string, parent_nodes: string) { render(block: Block, parent_node: string, parent_nodes: string) {
const name = this.var; const name = this.var;
const in_head = parent_node === 'document.head';
const needs_anchors = !parent_node || in_head;
// if in head always needs anchors
if (in_head) {
this.prev = null;
this.next = null;
}
// TODO use is_dom_node instead of type === 'Element'? // TODO use is_dom_node instead of type === 'Element'?
const needs_anchor_before = this.prev ? this.prev.node.type !== 'Element' : !parent_node; const needs_anchor_before = this.prev ? this.prev.node.type !== 'Element' : needs_anchors;
const needs_anchor_after = this.next ? this.next.node.type !== 'Element' : !parent_node; const needs_anchor_after = this.next ? this.next.node.type !== 'Element' : needs_anchors;
const anchor_before = needs_anchor_before const anchor_before = needs_anchor_before
? block.get_unique_name(`${name}_before`) ? block.get_unique_name(`${name}_before`)
@ -90,7 +99,7 @@ export default class RawMustacheTagWrapper extends Tag {
block.builders.mount.add_line(insert(init)); block.builders.mount.add_line(insert(init));
if (!parent_node) { if (needs_anchors) {
block.builders.destroy.add_conditional('detaching', needs_anchor_before block.builders.destroy.add_conditional('detaching', needs_anchor_before
? `${detach}\n@detach(${anchor_before});` ? `${detach}\n@detach(${anchor_before});`
: detach); : detach);

@ -140,6 +140,10 @@ export default function(node: Element, renderer: Renderer, options: RenderOption
node.bindings.forEach(binding => { node.bindings.forEach(binding => {
const { name, expression } = binding; const { name, expression } = binding;
if (binding.is_readonly) {
return;
}
if (name === 'group') { if (name === 'group') {
// TODO server-render group bindings // TODO server-render group bindings
} else { } else {

@ -133,4 +133,5 @@ export interface Var {
initialised?: boolean; initialised?: boolean;
hoistable?: boolean; hoistable?: boolean;
subscribable?: boolean; subscribable?: boolean;
} is_reactive_dependency?: boolean;
}

@ -22,15 +22,14 @@ export function create_animation(node, from, fn, params) {
let started = false; let started = false;
let name; let name;
const css_text = node.style.cssText;
function start() { function start() {
if (css) { if (css) {
if (delay) node.style.cssText = css_text; // TODO create delayed animation instead? name = create_rule(node, 0, 1, duration, delay, easing, css);
name = create_rule(node, 0, 1, duration, 0, easing, css);
} }
started = true; if (!delay) {
started = true;
}
} }
function stop() { function stop() {
@ -40,7 +39,7 @@ export function create_animation(node, from, fn, params) {
loop(now => { loop(now => {
if (!started && now >= start_time) { if (!started && now >= start_time) {
start(); started = true;
} }
if (started && now >= end) { if (started && now >= end) {
@ -61,11 +60,7 @@ export function create_animation(node, from, fn, params) {
return true; return true;
}); });
if (delay) { start();
if (css) node.style.cssText += css(0, 1);
} else {
start();
}
tick(0, 1); tick(0, 1);

@ -46,7 +46,7 @@ type SubscribeInvalidateTuple<T> = [Subscriber<T>, Invalidater<T>];
/** /**
* Creates a `Readable` store that allows reading by subscription. * Creates a `Readable` store that allows reading by subscription.
* @param value initial value * @param value initial value
* @param start start and stop notifications for subscriptions * @param {StartStopNotifier}start start and stop notifications for subscriptions
*/ */
export function readable<T>(value: T, start: StartStopNotifier<T>): Readable<T> { export function readable<T>(value: T, start: StartStopNotifier<T>): Readable<T> {
return { return {
@ -56,8 +56,8 @@ export function readable<T>(value: T, start: StartStopNotifier<T>): Readable<T>
/** /**
* Create a `Writable` store that allows both updating and reading by subscription. * Create a `Writable` store that allows both updating and reading by subscription.
* @param value initial value * @param {*=}value initial value
* @param start start and stop notifications for subscriptions * @param {StartStopNotifier=}start start and stop notifications for subscriptions
*/ */
export function writable<T>(value: T, start: StartStopNotifier<T> = noop): Writable<T> { export function writable<T>(value: T, start: StartStopNotifier<T> = noop): Writable<T> {
let stop: Unsubscriber; let stop: Unsubscriber;
@ -110,9 +110,9 @@ type StoresValues<T> = T extends Readable<infer U> ? U :
/** /**
* Derived value store by synchronizing one or more readable stores and * Derived value store by synchronizing one or more readable stores and
* applying an aggregation function over its input values. * applying an aggregation function over its input values.
* @param stores input stores * @param {Stores} stores input stores
* @param fn function callback that aggregates the values * @param {function(Stores=, function(*)=):*}fn function callback that aggregates the values
* @param initial_value when used asynchronously * @param {*=}initial_value when used asynchronously
*/ */
export function derived<T, S extends Stores>( export function derived<T, S extends Stores>(
stores: S, stores: S,

2
store.d.ts vendored

@ -1 +1 @@
export * from './dist/store'; export * from './types/store';

@ -67,7 +67,7 @@ function instance($$self, $$props, $$invalidate) {
const writable_props = ['name']; const writable_props = ['name'];
Object.keys($$props).forEach(key => { Object.keys($$props).forEach(key => {
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`); if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(`<Component> was created with unknown prop '${key}'`);
}); });
$$self.$set = $$props => { $$self.$set = $$props => {

@ -153,7 +153,7 @@ function instance($$self, $$props, $$invalidate) {
const writable_props = ['things', 'foo', 'bar', 'baz']; const writable_props = ['things', 'foo', 'bar', 'baz'];
Object.keys($$props).forEach(key => { Object.keys($$props).forEach(key => {
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`); if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(`<Component> was created with unknown prop '${key}'`);
}); });
$$self.$set = $$props => { $$self.$set = $$props => {

@ -153,7 +153,7 @@ function instance($$self, $$props, $$invalidate) {
const writable_props = ['things', 'foo']; const writable_props = ['things', 'foo'];
Object.keys($$props).forEach(key => { Object.keys($$props).forEach(key => {
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`); if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(`<Component> was created with unknown prop '${key}'`);
}); });
$$self.$set = $$props => { $$self.$set = $$props => {

@ -67,7 +67,7 @@ function instance($$self, $$props, $$invalidate) {
const writable_props = ['foo']; const writable_props = ['foo'];
Object.keys($$props).forEach(key => { Object.keys($$props).forEach(key => {
if (!writable_props.includes(key)) console.warn(`<Component> was created with unknown prop '${key}'`); if (!writable_props.includes(key) && !key.startsWith('$$')) console.warn(`<Component> was created with unknown prop '${key}'`);
}); });
$$self.$set = $$props => { $$self.$set = $$props => {

@ -29,7 +29,7 @@ function instance($$self, $$props, $$invalidate) {
$$self.$$.update = ($$dirty = { x: 1, b: 1 }) => { $$self.$$.update = ($$dirty = { x: 1, b: 1 }) => {
if ($$dirty.x) { $$invalidate('b', b = x); } if ($$dirty.x) { $$invalidate('b', b = x); }
if ($$dirty.b) { $$invalidate('a', a = b); } if ($$dirty.b) { a = b; }
}; };
return { x }; return { x };

@ -17,26 +17,25 @@ function create_fragment(ctx) {
}; };
} }
let a = 1;
let b = 2;
function instance($$self, $$props, $$invalidate) { function instance($$self, $$props, $$invalidate) {
let { a = 1, b = 2 } = $$props;
let max; $$self.$set = $$props => {
if ('a' in $$props) $$invalidate('a', a = $$props.a);
if ('b' in $$props) $$invalidate('b', b = $$props.b);
};
$$self.$$.update = ($$dirty = { a: 1, b: 1 }) => { $$self.$$.update = ($$dirty = { a: 1, b: 1 }) => {
if ($$dirty.a || $$dirty.b) { $$invalidate('max', max = Math.max(a, b)); } if ($$dirty.a || $$dirty.b) { console.log('max', Math.max(a, b)); }
}; };
return {}; return { a, b };
} }
class Component extends SvelteComponent { class Component extends SvelteComponent {
constructor(options) { constructor(options) {
super(); super();
init(this, options, instance, create_fragment, safe_not_equal, []); init(this, options, instance, create_fragment, safe_not_equal, ["a", "b"]);
} }
} }

@ -1,7 +1,6 @@
<script> <script>
let a = 1; export let a = 1;
let b = 2; export let b = 2;
let max; $: console.log('max', Math.max(a, b));
$: max = Math.max(a, b);
</script> </script>

@ -0,0 +1,78 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
append,
detach,
element,
init,
insert,
noop,
safe_not_equal,
set_data,
text
} from "svelte/internal";
import { onMount } from "svelte";
function create_fragment(ctx) {
var p, t;
return {
c() {
p = element("p");
t = text(ctx.y);
},
m(target, anchor) {
insert(target, p, anchor);
append(p, t);
},
p(changed, ctx) {
if (changed.y) {
set_data(t, ctx.y);
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching) {
detach(p);
}
}
};
}
function instance($$self, $$props, $$invalidate) {
let a, b, c;
onMount(() => {
const interval = setInterval(() => {
$$invalidate('b', b += 1);
c += 1;
console.log(b, c);
}, 1000);
return () => clearInterval(interval);
});
let x, y;
$$self.$$.update = ($$dirty = { a: 1, b: 1 }) => {
if ($$dirty.a) { x = a * 2; }
if ($$dirty.b) { $$invalidate('y', y = b * 2); }
};
return { y };
}
class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, []);
}
}
export default Component;

@ -0,0 +1,21 @@
<script>
import { onMount } from 'svelte';
let a, b, c;
onMount(() => {
const interval = setInterval(() => {
b += 1;
c += 1;
console.log(b, c);
}, 1000);
return () => clearInterval(interval);
});
$: x = a * 2;
$: y = b * 2;
</script>
<p>{y}</p>

@ -0,0 +1,7 @@
<script>
export let foo = undefined;
</script>
<div>{foo}</div>
<div>{JSON.stringify($$props)}</div>

@ -0,0 +1,7 @@
export default {
compileOptions: {
dev: true
},
warnings: []
};

@ -0,0 +1,5 @@
<script>
import Foo from './Foo.svelte';
</script>
<Foo fo="sho"/>

@ -0,0 +1,6 @@
<script>
export let answer;
</script>
<h1>{answer}</h1>
<div><slot></slot></div>

@ -0,0 +1,7 @@
export default {
compileOptions: {
dev: true
},
warnings: []
};

@ -0,0 +1,7 @@
<script>
import Foo from './Foo.svelte';
</script>
<Foo answer={42}>
bar
</Foo>

@ -9,4 +9,4 @@ export default {
component.condition = true; component.condition = true;
assert.equal(window.document.title, 'woo!!!'); assert.equal(window.document.title, 'woo!!!');
} }
}; };

@ -6,4 +6,4 @@
{#if condition} {#if condition}
<title>woo!!!</title> <title>woo!!!</title>
{/if} {/if}
</svelte:head> </svelte:head>

@ -0,0 +1,14 @@
export default {
props: {
condition: false
},
test({ assert, component, target, window }) {
assert.equal(window.document.title, '');
assert.equal(Boolean(window.document.getElementById('meta')), true);
component.condition = true;
assert.equal(window.document.title, 'woo!!!');
assert.equal(window.document.getElementById('meta'), null);
}
};

@ -0,0 +1,11 @@
<script>
export let condition;
</script>
<svelte:head>
{#if condition}
<title>woo!!!</title>
{:else}
<meta id="meta" name="title" content="woo!!!"/>
{/if}
</svelte:head>

@ -0,0 +1,19 @@
const foo = '<script type="application/json">{ "foo": "true" }</script>';
const bar = '<script type="application/json">{ "bar": "true" }</script>';
export default {
props: {
condition: false,
foo,
bar
},
test({ assert, component, window }) {
assert.equal(window.document.head.innerHTML.includes(foo), false);
assert.equal(window.document.head.innerHTML.includes(bar), true);
component.condition = true;
assert.equal(window.document.head.innerHTML.includes(foo), true);
assert.equal(window.document.head.innerHTML.includes(bar), false);
}
};

@ -0,0 +1,11 @@
<script>
export let condition, foo, bar;
</script>
<svelte:head>
{#if condition}
{@html foo}
{:else}
{@html bar}
{/if}
</svelte:head>

@ -0,0 +1,11 @@
<script>
export let bar;
</script>
<svelte:head>
<meta id="meta" name="title" content="bar!!!"/>
{#if true}
{@html bar}
{/if}
<title>bar!!!</title>
</svelte:head>

@ -0,0 +1,7 @@
<script>
export let foo;
</script>
<svelte:head>
{@html foo}
</svelte:head>

@ -0,0 +1,26 @@
const foo = '<script type="application/json">{ "foo": "true" }</script>';
const bar = '<script type="application/json">{ "bar": "true" }</script>';
export default {
props: {
condition: 1,
foo,
bar
},
test({ assert, component, window }) {
assert.equal(window.document.head.innerHTML.includes(foo), true);
component.condition = false;
assert.equal(window.document.head.innerHTML.includes(foo), false);
component.condition = 2;
assert.equal(window.document.title, 'bar!!!');
assert.equal(window.document.head.innerHTML.includes(bar), true);
assert.equal(Boolean(window.document.getElementById('meta')), true);
component.condition = false;
assert.equal(window.document.head.innerHTML.includes(bar), false);
assert.equal(window.document.getElementById('meta'), null);
}
};

@ -0,0 +1,12 @@
<script>
import Foo from './Foo.svelte';
import Bar from './Bar.svelte';
export let condition, foo, bar;
</script>
{#if condition === 1}
<Foo {foo} />
{:else if condition === 2}
<Bar {bar} />
{/if}

@ -1,7 +1,7 @@
<script> <script>
import { beforeUpdate, onMount } from 'svelte'; import { beforeUpdate, onMount } from 'svelte';
let mounted; let mounted = false;
export let count = 0; export let count = 0;
export let foo = { bar: 'baz' }; export let foo = { bar: 'baz' };
@ -14,4 +14,5 @@
}); });
</script> </script>
<h3>Called {count} times.</h3> <h3>Called {count} times.</h3>
<p>{foo.bar} {mounted}</p>

@ -1,16 +1,35 @@
export default { export default {
immutable: true, immutable: true,
html: `<div><h3>Called 1 times.</h3></div>`, html: `
<div>
<h3>Called 1 times.</h3>
<p>baz true</p>
</div>
`,
ssrHtml: `<div><h3>Called 0 times.</h3></div>`, ssrHtml: `
<div>
<h3>Called 0 times.</h3>
<p>baz false</p>
</div>`,
test({ assert, component, target, window }) { test({ assert, component, target }) {
var nested = component.nested; var nested = component.nested;
assert.htmlEqual(target.innerHTML, `<div><h3>Called 1 times.</h3></div>`); assert.htmlEqual(target.innerHTML, `
<div>
<h3>Called 1 times.</h3>
<p>baz true</p>
</div>
`);
nested.foo = nested.foo; nested.foo = nested.foo;
assert.htmlEqual(target.innerHTML, `<div><h3>Called 1 times.</h3></div>`); assert.htmlEqual(target.innerHTML, `
<div>
<h3>Called 1 times.</h3>
<p>baz true</p>
</div>
`);
} }
}; };

@ -5,5 +5,5 @@
</script> </script>
<div> <div>
<Nested bind:this={nested} /> <Nested bind:this={nested} />
</div> </div>

@ -0,0 +1,4 @@
<div></div>
<audio></audio>
<video></video>
<input type="file">

@ -0,0 +1,44 @@
<script>
export let clientWidth = 1;
export let clientHeight = 2;
export let offsetHeight = 3;
export let offsetWidth = 4;
export let audioDuration = 5;
export let audioBuffered = 6;
export let audioSeekable = 7;
export let audioPlayed = 8;
export let videoDuration = 9;
export let videoBuffered = 10;
export let videoSeekable = 11;
export let videoPlayed = 12;
export let value = '/some/file';
</script>
<div
bind:clientWidth
bind:clientHeight
bind:offsetWidth
bind:offsetHeight
></div>
<audio
bind:duration="{audioDuration}"
bind:buffered="{audioBuffered}"
bind:seekable="{audioSeekable}"
bind:played="{audioPlayed}"
></audio>
<video
bind:duration="{videoDuration}"
bind:buffered="{videoBuffered}"
bind:seekable="{videoSeekable}"
bind:played="{videoPlayed}"
></video>
<input
type="file"
bind:value
/>

2
transition.d.ts vendored

@ -1 +1 @@
export * from './dist/transition'; export * from './types/transition';

@ -2,8 +2,8 @@
"compilerOptions": { "compilerOptions": {
"target": "es2015", "target": "es2015",
"module": "es6", "module": "es6",
"declarationDir": "./dist", "declarationDir": "./types",
"outDir": "./dist", "outDir": "./types",
"declaration": true, "declaration": true,
"noImplicitThis": true, "noImplicitThis": true,
"noEmitOnError": true, "noEmitOnError": true,
@ -30,6 +30,6 @@
"src/**/*" "src/**/*"
], ],
"exclude": [ "exclude": [
"dist" "types"
] ]
} }

Loading…
Cancel
Save