various fixes and test updates

pull/1839/head
Rich Harris 7 years ago
parent 3ec39e6eab
commit d31bd771cf

@ -523,6 +523,7 @@ export default class Component {
// TODO unindent
this.extract_imports_and_exports(script.content, this.imports, this.module_exports);
remove_indentation(this.code, script.content);
this.module_javascript = this.extract_javascript(script);
}

@ -65,6 +65,10 @@ export default function ssr(
map: ${css.map ? stringify(css.map.toString()) : 'null'}
};`}
${component.module_javascript}
${component.fully_hoisted.length > 0 && component.fully_hoisted.join('\n\n')}
const ${name} = @create_ssr_component(($$result, $$props, $$bindings, $$slots) => {
${setup}

@ -16,18 +16,14 @@ export function remove_indentation(code: MagicString, node: Node) {
}
});
let dirty = false;
const str = code.original.slice(node.start, node.end);
const str = code.original
.slice(node.start, node.end)
.replace(pattern, (match, i) => {
const index = node.start + i;
while (excluded[0] && excluded[0].end < index) excluded.shift();
if (excluded[0] && excluded[0].start < index) return match;
let match;
while (match = pattern.exec(str)) {
const index = node.start + match.index;
while (excluded[0] && excluded[0].end < index) excluded.shift();
if (excluded[0] && excluded[0].start < index) continue;
dirty = true;
return '';
});
if (dirty) code.overwrite(node.start, node.end, str);
code.remove(index, index + indent.length);
}
}

@ -2,6 +2,8 @@
import { SvelteComponent as SvelteComponent_1, flush, init, noop, run, safe_not_equal } from "svelte/internal.js";
function create_fragment(component, ctx) {
var current;
return {
c: noop,
m: noop,

@ -3,6 +3,8 @@ import { SvelteComponent as SvelteComponent_1, flush, init, noop, run, safe_not_
import { onMount } from "svelte";
function create_fragment(component, ctx) {
var current;
return {
c: noop,
m: noop,

@ -1,13 +1,9 @@
/* generated by Svelte vX.Y.Z-alpha1 */
import { SvelteComponent as SvelteComponent_1, init, noop, run, safe_not_equal } from "svelte/internal.js";
const SOME_CONSTANT = 42;
function foo(bar) {
console.log(bar);
}
function create_fragment(component, ctx) {
var current;
return {
c: noop,
m: noop,
@ -18,10 +14,16 @@ function create_fragment(component, ctx) {
};
}
const SOME_CONSTANT = 42;
function foo(bar) {
console.log(bar);
}
class SvelteComponent extends SvelteComponent_1 {
constructor(options) {
super();
init(this, options, define, create_fragment, safe_not_equal);
init(this, options, noop, create_fragment, safe_not_equal);
}
get foo() {

@ -1,6 +1,6 @@
/* generated by Svelte vX.Y.Z-alpha1 */
import { create_ssr_component } from "svelte/internal.js";
import { onMount, onDestroy } from "svelte";
import { onDestroy, onMount } from "svelte";
function preload(input) {
return output;
@ -23,6 +23,10 @@ const SvelteComponent = create_ssr_component(($$result, $$props, $$bindings, $$s
console.log('onDestroy');
});
/* HOISTED */
/* HOISTED */
return ``;
});

@ -9,32 +9,38 @@
"end": 61,
"type": "Element",
"name": "textarea",
"attributes": [],
"children": [
"attributes": [
{
"start": 10,
"end": 40,
"type": "Text",
"data": "\n\t<p>not actually an element. "
},
{
"start": 40,
"end": 45,
"type": "MustacheTag",
"expression": {
"type": "Identifier",
"start": 41,
"end": 44,
"name": "foo"
}
},
{
"start": 45,
"end": 50,
"type": "Text",
"data": "</p>\n"
"type": "Attribute",
"name": "value",
"value": [
{
"start": 10,
"end": 40,
"type": "Text",
"data": "\n\t<p>not actually an element. "
},
{
"start": 40,
"end": 45,
"type": "MustacheTag",
"expression": {
"type": "Identifier",
"start": 41,
"end": 44,
"name": "foo"
}
},
{
"start": 45,
"end": 50,
"type": "Text",
"data": "</p>\n"
}
]
}
]
],
"children": []
}
]
},

Loading…
Cancel
Save