Skip to content

Commit

Permalink
[chore] Fix CI (#8160)
Browse files Browse the repository at this point in the history
* ci build

* fix test

* add test for #7938
  • Loading branch information
baseballyama authored Jan 2, 2023
1 parent 26c0d3f commit e1a1c7f
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 17 deletions.
8 changes: 6 additions & 2 deletions generate-type-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
const { execSync } = require('child_process');
const { readFileSync, writeFileSync } = require('fs');

execSync('tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly');

try {
execSync('tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emitDeclarationOnly');
} catch (err) {
console.error(err.stderr.toString());
throw err;
}
// We need to add these types to the .d.ts files here because if we add them before building, the build will fail,
// because the TS->JS transformation doesn't know these exports are types and produces code that fails at runtime.
// We can't use `export type` syntax either because the TS version we're on doesn't have this feature yet.
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/transition/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export function draw(node: SVGElement & { getTotalLength(): number }, {
delay,
duration,
easing,
css: (t, u) => `
css: (_, u) => `
stroke-dasharray: ${len};
stroke-dashoffset: ${u * len};
`
Expand Down
25 changes: 14 additions & 11 deletions test/js/samples/svelte-element-event-handlers/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ function create_dynamic_element(ctx) {

return {
c() {
svelte_element1 = element("a");
svelte_element0 = element("span");
svelte_element1 = element(a);
svelte_element0 = element(span);

if ((/-/).test("span")) {
if ((/-/).test(span)) {
set_custom_element_data_map(svelte_element0, svelte_element0_data);
} else {
set_attributes(svelte_element0, svelte_element0_data);
}

if ((/-/).test("a")) {
if ((/-/).test(a)) {
set_custom_element_data_map(svelte_element1, svelte_element1_data);
} else {
set_attributes(svelte_element1, svelte_element1_data);
Expand All @@ -72,15 +72,15 @@ function create_dynamic_element(ctx) {
p(ctx, dirty) {
svelte_element0_data = get_spread_update(svelte_element0_levels, [{ class: "inner" }]);

if ((/-/).test("span")) {
if ((/-/).test(span)) {
set_custom_element_data_map(svelte_element0, svelte_element0_data);
} else {
set_attributes(svelte_element0, svelte_element0_data);
}

svelte_element1_data = get_spread_update(svelte_element1_levels, [{ class: "outer" }]);

if ((/-/).test("a")) {
if ((/-/).test(a)) {
set_custom_element_data_map(svelte_element1, svelte_element1_data);
} else {
set_attributes(svelte_element1, svelte_element1_data);
Expand All @@ -95,9 +95,9 @@ function create_dynamic_element(ctx) {
}

function create_fragment(ctx) {
let previous_tag = "a";
let previous_tag = a;
let svelte_element_anchor;
let svelte_element = "a" && create_dynamic_element(ctx);
let svelte_element = a && create_dynamic_element(ctx);

return {
c() {
Expand All @@ -109,12 +109,12 @@ function create_fragment(ctx) {
insert(target, svelte_element_anchor, anchor);
},
p(ctx, [dirty]) {
if ("a") {
if (a) {
if (!previous_tag) {
svelte_element = create_dynamic_element(ctx);
svelte_element.c();
svelte_element.m(svelte_element_anchor.parentNode, svelte_element_anchor);
} else if (safe_not_equal(previous_tag, "a")) {
} else if (safe_not_equal(previous_tag, a)) {
svelte_element.d(1);
svelte_element = create_dynamic_element(ctx);
svelte_element.c();
Expand All @@ -127,7 +127,7 @@ function create_fragment(ctx) {
svelte_element = null;
}

previous_tag = "a";
previous_tag = a;
},
i: noop,
o: noop,
Expand All @@ -138,6 +138,9 @@ function create_fragment(ctx) {
};
}

const a = 'a';
const span = 'span';

function instance($$self) {
function keydown_handler(event) {
bubble.call(this, $$self, event);
Expand Down
11 changes: 8 additions & 3 deletions test/js/samples/svelte-element-event-handlers/input.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<svelte:element class="outer" this="a" on:keydown on:keyup>
<svelte:element class="inner" this="span" on:keydown on:keyup></svelte:element>
</svelte:element>
<script>
const a = 'a';
const span = 'span';
</script>

<svelte:element this={a} class='outer' on:keydown on:keyup>
<svelte:element this={span} class='inner' on:keydown on:keyup />
</svelte:element>
41 changes: 41 additions & 0 deletions test/js/samples/svelte-element-static/expected.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* generated by Svelte vX.Y.Z */
import {
SvelteComponent,
attr,
detach,
element,
init,
insert,
noop,
safe_not_equal
} from "svelte/internal";

function create_fragment(ctx) {
let a;

return {
c() {
a = element("a");
a.innerHTML = `<span class="inner"></span>`;
attr(a, "class", "outer");
},
m(target, anchor) {
insert(target, a, anchor);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching) detach(a);
}
};
}

class Component extends SvelteComponent {
constructor(options) {
super();
init(this, options, null, create_fragment, safe_not_equal, {});
}
}

export default Component;
3 changes: 3 additions & 0 deletions test/js/samples/svelte-element-static/input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<svelte:element this='a' class='outer'>
<svelte:element this='span' class='inner' />
</svelte:element>

0 comments on commit e1a1c7f

Please sign in to comment.