From 773b4ed94112666aabb9446ba55b661802f9e2c3 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Fri, 14 Jun 2019 22:41:50 +0200 Subject: [PATCH] remove support for refs not really needed, as render functions work with DOM nodes that can be easily stored as a side-effect of the render fn --- src/ui/web/Template.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/ui/web/Template.js b/src/ui/web/Template.js index 3150f172..3d0d47b5 100644 --- a/src/ui/web/Template.js +++ b/src/ui/web/Template.js @@ -20,7 +20,6 @@ import { setAttribute, text, TAG_NAMES } from "./html.js"; export default class Template { constructor(value, render) { this._value = value; - this._refs = {}; this._eventListeners = []; this._bindings = []; this._render = render; @@ -37,10 +36,6 @@ export default class Template { return this._root; } - ref(name) { - return this._refs[name]; - } - update(value) { this._value = value; for (const binding of this._bindings) { @@ -60,8 +55,6 @@ export default class Template { } } - _addRef(name, node) { - this._refs[name] = node; } _addEventListener(node, name, fn) { @@ -112,9 +105,7 @@ export default class Template { if (attributes) { for(let [key, value] of Object.entries(attributes)) { const isFn = typeof value === "function"; - if (key === "ref") { - this._refs[value] = node; - } else if (key.startsWith("on") && key.length > 2 && isFn) { + if (key.startsWith("on") && key.length > 2 && isFn) { const eventName = key.substr(2, 1).toLowerCase() + key.substr(3); const handler = value; this._addEventListener(node, eventName, handler);