|
|
@ -12,8 +12,7 @@ interface T$$ {
|
|
|
|
update: () => void;
|
|
|
|
update: () => void;
|
|
|
|
callbacks: any;
|
|
|
|
callbacks: any;
|
|
|
|
after_update: any[];
|
|
|
|
after_update: any[];
|
|
|
|
props: any;
|
|
|
|
props: Record<string, 0 | string>;
|
|
|
|
renamed_props: any;
|
|
|
|
|
|
|
|
fragment: null|any;
|
|
|
|
fragment: null|any;
|
|
|
|
not_equal: any;
|
|
|
|
not_equal: any;
|
|
|
|
before_update: any[];
|
|
|
|
before_update: any[];
|
|
|
@ -23,13 +22,12 @@ interface T$$ {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function bind(component, name, callback) {
|
|
|
|
export function bind(component, name, callback) {
|
|
|
|
if (component.$$.props.indexOf(name) === -1) return;
|
|
|
|
if (name in component.$$.props) {
|
|
|
|
if (component.$$.renamed_props && name in component.$$.renamed_props) {
|
|
|
|
name = component.$$.props[name] || name;
|
|
|
|
name = component.$$.renamed_props[name];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
component.$$.bound[name] = callback;
|
|
|
|
component.$$.bound[name] = callback;
|
|
|
|
callback(component.$$.ctx[name]);
|
|
|
|
callback(component.$$.ctx[name]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function mount_component(component, target, anchor) {
|
|
|
|
export function mount_component(component, target, anchor) {
|
|
|
|
const { fragment, on_mount, on_destroy, after_update } = component.$$;
|
|
|
|
const { fragment, on_mount, on_destroy, after_update } = component.$$;
|
|
|
@ -74,19 +72,18 @@ function make_dirty(component, key) {
|
|
|
|
component.$$.dirty[key] = true;
|
|
|
|
component.$$.dirty[key] = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function init(component, options, instance, create_fragment, not_equal, prop_names, renamed_props) {
|
|
|
|
export function init(component, options, instance, create_fragment, not_equal, props) {
|
|
|
|
const parent_component = current_component;
|
|
|
|
const parent_component = current_component;
|
|
|
|
set_current_component(component);
|
|
|
|
set_current_component(component);
|
|
|
|
|
|
|
|
|
|
|
|
const props = options.props || {};
|
|
|
|
const prop_values = options.props || {};
|
|
|
|
|
|
|
|
|
|
|
|
const $$: T$$ = component.$$ = {
|
|
|
|
const $$: T$$ = component.$$ = {
|
|
|
|
fragment: null,
|
|
|
|
fragment: null,
|
|
|
|
ctx: null,
|
|
|
|
ctx: null,
|
|
|
|
|
|
|
|
|
|
|
|
// state
|
|
|
|
// state
|
|
|
|
props: prop_names,
|
|
|
|
props,
|
|
|
|
renamed_props,
|
|
|
|
|
|
|
|
update: noop,
|
|
|
|
update: noop,
|
|
|
|
not_equal,
|
|
|
|
not_equal,
|
|
|
|
bound: blank_object(),
|
|
|
|
bound: blank_object(),
|
|
|
@ -106,14 +103,14 @@ export function init(component, options, instance, create_fragment, not_equal, p
|
|
|
|
let ready = false;
|
|
|
|
let ready = false;
|
|
|
|
|
|
|
|
|
|
|
|
$$.ctx = instance
|
|
|
|
$$.ctx = instance
|
|
|
|
? instance(component, props, (key, ret, value = ret) => {
|
|
|
|
? instance(component, prop_values, (key, ret, value = ret) => {
|
|
|
|
if ($$.ctx && not_equal($$.ctx[key], $$.ctx[key] = value)) {
|
|
|
|
if ($$.ctx && not_equal($$.ctx[key], $$.ctx[key] = value)) {
|
|
|
|
if ($$.bound[key]) $$.bound[key](value);
|
|
|
|
if ($$.bound[key]) $$.bound[key](value);
|
|
|
|
if (ready) make_dirty(component, key);
|
|
|
|
if (ready) make_dirty(component, key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
: props;
|
|
|
|
: prop_values;
|
|
|
|
|
|
|
|
|
|
|
|
$$.update();
|
|
|
|
$$.update();
|
|
|
|
ready = true;
|
|
|
|
ready = true;
|
|
|
|