Skip to content

Commit 9d11827

Browse files
committed
add has_prop helper
1 parent de2b1a6 commit 9d11827

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/runtime/internal/Component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler';
22
import { current_component, set_current_component } from './lifecycle';
3-
import { blank_object, is_function, run, run_all, noop } from './utils';
3+
import { blank_object, is_function, run, run_all, noop, has_prop } from './utils';
44
import { children } from './dom';
55
import { transition_in } from './transitions';
66

@@ -22,7 +22,7 @@ interface T$$ {
2222
}
2323

2424
export function bind(component, name, callback) {
25-
if (component.$$.props.hasOwnProperty(name)) {
25+
if (has_prop(component.$$.props, name)) {
2626
name = component.$$.props[name] || name;
2727
component.$$.bound[name] = callback;
2828
callback(component.$$.ctx[name]);

src/runtime/internal/dom.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { has_prop } from "./utils";
2+
13
export function append(target: Node, node: Node) {
24
target.appendChild(node);
35
}
@@ -29,7 +31,7 @@ export function object_without_properties<T, K extends keyof T>(obj: T, exclude:
2931
const target = {} as Pick<T, Exclude<keyof T, K>>;
3032
for (const k in obj) {
3133
if (
32-
Object.prototype.hasOwnProperty.call(obj, k)
34+
has_prop(obj, k)
3335
// @ts-ignore
3436
&& exclude.indexOf(k) === -1
3537
) {

src/runtime/internal/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,5 @@ export function set_store_value(store, ret, value = ret) {
105105
store.set(value);
106106
return ret;
107107
}
108+
109+
export const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);

0 commit comments

Comments
 (0)