inject props

pull/1839/head
Rich Harris 7 years ago
parent f648bb6548
commit 578a2bca08

@ -133,6 +133,10 @@ export default class Component {
this.meta = process_meta(this, this.ast.html.children);
this.namespace = namespaces[this.meta.namespace] || this.meta.namespace;
if (this.meta.props) {
this.has_reactive_assignments = true;
}
if (options.customElement === true && !this.meta.tag) {
throw new Error(`No tag name specified`); // TODO better error
}

@ -60,6 +60,10 @@ function make_dirty(component, key) {
component.$$.dirty[key] = true;
}
function empty() {
return {};
}
export function init(component, options, define, create_fragment, not_equal) {
const previous_component = current_component;
set_current_component(component);
@ -68,7 +72,7 @@ export function init(component, options, define, create_fragment, not_equal) {
fragment: null,
// state
get: null,
get: empty,
set: noop,
inject_refs: noop,
not_equal,
@ -88,15 +92,11 @@ export function init(component, options, define, create_fragment, not_equal) {
binding_groups: []
};
define(component, key => {
define(component, options.props || {}, key => {
make_dirty(component, key);
if (component.$$.bound[key]) component.$$.bound[key](component.$$.get()[key]);
});
if (options.props) {
component.$$.set(options.props);
}
run_all(component.$$.before_render);
component.$$.fragment = create_fragment(component, component.$$.get());

@ -3,7 +3,7 @@ import * as fs from "fs";
import * as path from "path";
import { loadConfig, svelte } from "../helpers.js";
describe.only("js", () => {
describe("js", () => {
fs.readdirSync("test/js/samples").forEach(dir => {
if (dir[0] === ".") return;

@ -21,7 +21,7 @@ function tryToReadFile(file) {
const sveltePath = process.cwd();
describe("ssr", () => {
describe.only("ssr", () => {
before(() => {
require("../../register")({
extensions: ['.svelte', '.html'],

Loading…
Cancel
Save