mirror of https://github.com/sveltejs/svelte
feat: more efficient code generation when referencing globals (#12712)
* feat: more efficient code generation when referencing globals * update testpull/12735/head
parent
93cfa6cd69
commit
e66416bec7
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: more efficient code generation when referencing globals
|
@ -0,0 +1,32 @@
|
|||||||
|
import "svelte/internal/disclose-version";
|
||||||
|
import * as $ from "svelte/internal/client";
|
||||||
|
|
||||||
|
var root = $.template(`<p> </p> <p> </p> <!>`, 1);
|
||||||
|
|
||||||
|
export default function Purity($$anchor) {
|
||||||
|
let min = 0;
|
||||||
|
let max = 100;
|
||||||
|
let number = 50;
|
||||||
|
let value = 'hello';
|
||||||
|
var fragment = root();
|
||||||
|
var p = $.first_child(fragment);
|
||||||
|
var text = $.child(p);
|
||||||
|
|
||||||
|
text.nodeValue = Math.max(min, Math.min(max, number));
|
||||||
|
$.reset(p);
|
||||||
|
|
||||||
|
var p_1 = $.sibling($.sibling(p, true));
|
||||||
|
var text_1 = $.child(p_1);
|
||||||
|
|
||||||
|
text_1.nodeValue = location.href;
|
||||||
|
$.reset(p_1);
|
||||||
|
|
||||||
|
var node = $.sibling($.sibling(p_1, true));
|
||||||
|
|
||||||
|
Child(node, {
|
||||||
|
prop: encodeURIComponent(value),
|
||||||
|
$$legacy: true
|
||||||
|
});
|
||||||
|
|
||||||
|
$.append($$anchor, fragment);
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
import * as $ from "svelte/internal/server";
|
||||||
|
|
||||||
|
export default function Purity($$payload) {
|
||||||
|
let min = 0;
|
||||||
|
let max = 100;
|
||||||
|
let number = 50;
|
||||||
|
let value = 'hello';
|
||||||
|
|
||||||
|
$$payload.out += `<p>${$.escape(Math.max(min, Math.min(max, number)))}</p> <p>${$.escape(location.href)}</p> `;
|
||||||
|
Child($$payload, { prop: encodeURIComponent(value) });
|
||||||
|
$$payload.out += `<!---->`;
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<script>
|
||||||
|
let min = 0;
|
||||||
|
let max = 100;
|
||||||
|
let number = 50;
|
||||||
|
|
||||||
|
let value = 'hello';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>{Math.max(min, Math.min(max, number))}</p>
|
||||||
|
<p>{location.href}</p>
|
||||||
|
|
||||||
|
<Child prop={encodeURIComponent(value)} />
|
Loading…
Reference in new issue