Merge pull request #1930 from sveltejs/gh-1894

whitelist process, and fallback to globals
pull/1935/head
Rich Harris 6 years ago committed by GitHub
commit e7642db13d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -279,7 +279,7 @@ export default function dom(
const user_code = component.javascript || (
component.ast.js.length === 0 && filtered_props.length > 0
? `let { ${filtered_props.map(x => x.name === x.as ? x.as : `${x.as}: ${x.name}`).join(', ')} } = $$props;`
? `let { ${filtered_props.map(x => x.name).join(', ')} } = $$props;`
: null
);

@ -19,6 +19,7 @@ export default new Set([
'Object',
'parseFloat',
'parseInt',
'process',
'Promise',
'RegExp',
'Set',

@ -126,7 +126,9 @@ describe("runtime", () => {
global.window = window;
// Put the constructor on window for testing
if (config.before_test) config.before_test();
// Put things we need on window for testing
window.SvelteComponent = SvelteComponent;
const target = window.document.querySelector("main");
@ -208,6 +210,8 @@ describe("runtime", () => {
}
flush();
if (config.after_test) config.after_test();
});
});
}

@ -0,0 +1,11 @@
export default {
html: '<h1>Hello world!</h1>',
before_test() {
process.env.TMP_VAR = 'world';
},
after_test() {
delete process.env.TMP_VAR;
}
};

@ -114,6 +114,8 @@ describe("ssr", () => {
require("../../register")(compileOptions);
try {
if (config.before_test) config.before_test();
const Component = require(`../runtime/samples/${dir}/main.html`).default;
const { html } = Component.render(config.props, {
store: (config.store !== true) && config.store
@ -124,6 +126,8 @@ describe("ssr", () => {
} else if (config.html) {
assert.htmlEqual(html, config.html);
}
if (config.after_test) config.after_test();
} catch (err) {
if (config.error) {
if (typeof config.error === 'function') {

Loading…
Cancel
Save