update code-red, update some tests etc

pull/3539/head
Richard Harris 6 years ago
parent 42e1c8f191
commit da4d90004e

35
package-lock.json generated

@ -318,11 +318,6 @@
"integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==", "integrity": "sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg==",
"dev": true "dev": true
}, },
"astring": {
"version": "github:Rich-Harris/astring#9f675d470d1c758de5ec42724aa5dd2e1dabf919",
"from": "github:Rich-Harris/astring#generic-handler",
"dev": true
},
"async-limiter": { "async-limiter": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
@ -495,16 +490,15 @@
"dev": true "dev": true
}, },
"code-red": { "code-red": {
"version": "0.0.15", "version": "0.0.16",
"resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.15.tgz", "resolved": "https://registry.npmjs.org/code-red/-/code-red-0.0.16.tgz",
"integrity": "sha512-r3c5r7IFsgKw3IE+F1wkTOezvwZ1N6xXKAJ0Dfyrs+JxHVEWbPU+goKwbo6XCCc8ykO5IU5Pofq1BvuxiXMQHQ==", "integrity": "sha512-40SV6oWnBVVfUP+i8NYeTo9EQWtTnlZ17LIv91dKhLa6R/iZKqxOAV/5HEkj86EhLmNiRB7O6hEnga2jy0hoBA==",
"dev": true, "dev": true,
"requires": { "requires": {
"acorn": "^7.0.0", "acorn": "^7.0.0",
"astring": "github:Rich-Harris/astring#9f675d470d1c758de5ec42724aa5dd2e1dabf919",
"is-reference": "^1.1.3", "is-reference": "^1.1.3",
"periscopic": "^1.0.0", "periscopic": "^1.0.1",
"source-map": "^0.7.3" "sourcemap-codec": "^1.4.6"
} }
}, },
"codecov": { "codecov": {
@ -2727,12 +2721,23 @@
"dev": true "dev": true
}, },
"periscopic": { "periscopic": {
"version": "1.0.0", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/periscopic/-/periscopic-1.0.0.tgz", "resolved": "https://registry.npmjs.org/periscopic/-/periscopic-1.0.1.tgz",
"integrity": "sha512-ftydZZH2Ca4FdWJXDwQ1Uuz4VEBhh4jXuT1bprR4qg/zM2+FhulluBUxnQXI0olDqADmsQRE1eHLs42iIhNjtA==", "integrity": "sha512-JcSQ6sufVNGT04lPr2f2qGuJ2FCkZcbWBw0gQ8mzSVf9+6bEX9ea6l48+PdAekjJIHlEwSrqJND1TR2cC1FbtQ==",
"dev": true,
"requires": {
"is-reference": "^1.1.4"
},
"dependencies": {
"is-reference": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.1.4.tgz",
"integrity": "sha512-uJA/CDPO3Tao3GTrxYn6AwkM4nUPJiGGYu5+cB8qbC7WGFlrKZbiRo7SFKxUAEpFUfiHofWCXBUNhvYJMh+6zw==",
"dev": true, "dev": true,
"requires": { "requires": {
"is-reference": "^1.1.3" "@types/estree": "0.0.39"
}
}
} }
}, },
"pify": { "pify": {

@ -63,7 +63,7 @@
"acorn": "^7.0.0", "acorn": "^7.0.0",
"agadoo": "^1.1.0", "agadoo": "^1.1.0",
"c8": "^5.0.1", "c8": "^5.0.1",
"code-red": "0.0.15", "code-red": "0.0.16",
"codecov": "^3.5.0", "codecov": "^3.5.0",
"css-tree": "1.0.0-alpha22", "css-tree": "1.0.0-alpha22",
"eslint": "^6.3.0", "eslint": "^6.3.0",

@ -283,7 +283,7 @@ export default function dom(
const instance_javascript = component.extract_javascript(component.ast.instance); const instance_javascript = component.extract_javascript(component.ast.instance);
const has_definition = ( const has_definition = (
instance_javascript || instance_javascript.length > 0 ||
filtered_props.length > 0 || filtered_props.length > 0 ||
uses_props || uses_props ||
component.partly_hoisted.length > 0 || component.partly_hoisted.length > 0 ||

@ -33,7 +33,7 @@ export default function add_actions(
); );
if (dependencies && dependencies.length > 0) { if (dependencies && dependencies.length > 0) {
let condition = x`typeof ${id}.update === 'function'`; let condition = x`@is_function(${id}.update)`;
// TODO can this case be handled more elegantly? // TODO can this case be handled more elegantly?
if (dependencies.length > 0) { if (dependencies.length > 0) {
@ -51,7 +51,7 @@ export default function add_actions(
} }
block.chunks.destroy.push( block.chunks.destroy.push(
b`if (${id} && typeof ${id}.destroy === 'function') ${id}.destroy();` b`if (${id} && @is_function(${id}.destroy)) ${id}.destroy();`
); );
}); });
} }

@ -1,62 +1,53 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
detach, detach,
element, element,
init, init,
insert, insert,
is_function,
noop, noop,
safe_not_equal safe_not_equal
} from "svelte/internal"; } from "svelte/internal";
function create_fragment(ctx) { function create_fragment(ctx) {
var button, foo_action; let button;
let foo_action;
return { return {
c() { c() {
button = element("button"); button = element("button");
button.textContent = "foo"; button.textContent = "foo";
}, },
m(target, anchor) { m(target, anchor) {
insert(target, button, anchor); insert(target, button, anchor);
foo_action = foo.call(null, button, ctx.foo_function) || {}; foo_action = foo.call(null, button, ctx.foo_function) || ({});
}, },
p(changed, ctx) { p(changed, ctx) {
if (typeof foo_action.update === 'function' && changed.bar) { if (is_function(foo_action.update) && changed.bar) foo_action.update.call(null, ctx.foo_function);
foo_action.update.call(null, ctx.foo_function);
}
}, },
i: noop, i: noop,
o: noop, o: noop,
d(detaching) { d(detaching) {
if (detaching) { if (detaching) detach(button);
detach(button); if (foo_action && is_function(foo_action.destroy)) foo_action.destroy();
}
if (foo_action && typeof foo_action.destroy === 'function') foo_action.destroy();
} }
}; };
} }
function handleFoo(bar) { function foo(node, callback) {
console.log(bar);
} }
function foo(node, callback) { function handleFoo(bar) {
// code goes here console.log(bar);
} }
function instance($$self, $$props, $$invalidate) { function instance($$self, $$props, $$invalidate) {
let { bar } = $$props; let { bar } = $$props;
const foo_function = () => handleFoo(bar); const foo_function = () => handleFoo(bar);
$$self.$set = $$props => { $$self.$set = $$props => {
if ('bar' in $$props) $$invalidate('bar', bar = $$props.bar); if ("bar" in $$props) $$invalidate("bar", bar = $$props.bar);
}; };
return { bar, foo_function }; return { bar, foo_function };

@ -1,4 +1,3 @@
/* generated by Svelte vX.Y.Z */
import { import {
SvelteComponent, SvelteComponent,
attr, attr,
@ -6,12 +5,14 @@ import {
element, element,
init, init,
insert, insert,
is_function,
noop, noop,
safe_not_equal safe_not_equal
} from "svelte/internal"; } from "svelte/internal";
function create_fragment(ctx) { function create_fragment(ctx) {
var a, link_action; let a;
let link_action;
return { return {
c() { c() {
@ -19,22 +20,16 @@ function create_fragment(ctx) {
a.textContent = "Test"; a.textContent = "Test";
attr(a, "href", "#"); attr(a, "href", "#");
}, },
m(target, anchor) { m(target, anchor) {
insert(target, a, anchor); insert(target, a, anchor);
link_action = link.call(null, a) || {}; link_action = link.call(null, a) || ({});
}, },
p: noop, p: noop,
i: noop, i: noop,
o: noop, o: noop,
d(detaching) { d(detaching) {
if (detaching) { if (detaching) detach(a);
detach(a); if (link_action && is_function(link_action.destroy)) link_action.destroy();
}
if (link_action && typeof link_action.destroy === 'function') link_action.destroy();
} }
}; };
} }
@ -45,13 +40,13 @@ function link(node) {
history.pushState(null, null, event.target.href); history.pushState(null, null, event.target.href);
} }
node.addEventListener('click', onClick); node.addEventListener("click", onClick);
return { return {
destroy() { destroy() {
node.removeEventListener('click', onClick); node.removeEventListener("click", onClick);
}
} }
};
} }
class Component extends SvelteComponent { class Component extends SvelteComponent {

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

Loading…
Cancel
Save