From a80093082152d4437f07d0af7e2ecd9e3fdd48f8 Mon Sep 17 00:00:00 2001 From: Marek Piasecki Date: Mon, 4 Feb 2019 10:41:48 +0100 Subject: [PATCH] update router tag according to Sindre's suggestion --- router_tag.imba | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/router_tag.imba b/router_tag.imba index 7ac3285..f3e74b2 100644 --- a/router_tag.imba +++ b/router_tag.imba @@ -5,10 +5,19 @@ require './not_found/not_found' tag router + prop component watch: yes + def setup @r = R - @t = Imba:TAGS + @component = null + @cache = {} + + def componentDidSet val, prev + removeChild(prev) if prev + appendChild(val) if val + self def render - self:__:A = self:__:A || {} - ( self:__:A[@r:view] || self:__:A[@r:view] = @t[@r:view.toUpperCase]() ).end + var view = @data || @r:view + component = @cache[view] ||= Imba.createElement(view,null,null,self) + component.end