diff --git a/src/generators/dom/visitors/EachBlock.ts b/src/generators/dom/visitors/EachBlock.ts index e0d941511e..03c0918ce0 100644 --- a/src/generators/dom/visitors/EachBlock.ts +++ b/src/generators/dom/visitors/EachBlock.ts @@ -160,7 +160,7 @@ function keyed( const last = block.getUniqueName(`${each_block}_last`); const expected = block.getUniqueName(`${each_block}_expected`); - block.addVariable(lookup, `Object.create(null)`); + block.addVariable(lookup, `@blankObject()`); block.addVariable(head); block.addVariable(last); diff --git a/src/shared/index.js b/src/shared/index.js index 001babe349..dcc2895831 100644 --- a/src/shared/index.js +++ b/src/shared/index.js @@ -4,6 +4,10 @@ export * from './dom.js'; export * from './transitions.js'; export * from './utils.js'; +export function blankObject() { + return Object.create(null); +} + export function destroy(detach) { this.destroy = noop; this.fire('destroy'); @@ -63,13 +67,8 @@ export function get(key) { export function init(component, options) { component.options = options; - component._observers = { - pre: Object.create(null), - post: Object.create(null) - }; - - component._handlers = Object.create(null); - + component._observers = { pre: blankObject(), post: blankObject() }; + component._handlers = blankObject(); component._root = options._root || component; component._yield = options._yield; component._bind = options._bind;