add has_prop helper

pull/3811/head
Richard Harris 5 years ago
parent de2b1a6a0d
commit 9d118275d3

@ -1,6 +1,6 @@
import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler';
import { current_component, set_current_component } from './lifecycle';
import { blank_object, is_function, run, run_all, noop } from './utils';
import { blank_object, is_function, run, run_all, noop, has_prop } from './utils';
import { children } from './dom';
import { transition_in } from './transitions';
@ -22,7 +22,7 @@ interface T$$ {
}
export function bind(component, name, callback) {
if (component.$$.props.hasOwnProperty(name)) {
if (has_prop(component.$$.props, name)) {
name = component.$$.props[name] || name;
component.$$.bound[name] = callback;
callback(component.$$.ctx[name]);

@ -1,3 +1,5 @@
import { has_prop } from "./utils";
export function append(target: Node, node: Node) {
target.appendChild(node);
}
@ -29,7 +31,7 @@ export function object_without_properties<T, K extends keyof T>(obj: T, exclude:
const target = {} as Pick<T, Exclude<keyof T, K>>;
for (const k in obj) {
if (
Object.prototype.hasOwnProperty.call(obj, k)
has_prop(obj, k)
// @ts-ignore
&& exclude.indexOf(k) === -1
) {

@ -105,3 +105,5 @@ export function set_store_value(store, ret, value = ret) {
store.set(value);
return ret;
}
export const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
Loading…
Cancel
Save