From 35966b24c1da0a5c2284f0152e02867ace6c4027 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Wed, 3 Aug 2016 13:02:55 -0700 Subject: [PATCH] ES5ify web-dev-listener.js --- app/assets/javascripts/web-dev-listener.js | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/web-dev-listener.js b/app/assets/javascripts/web-dev-listener.js index 54e2680ad..cc67305de 100644 --- a/app/assets/javascripts/web-dev-listener.js +++ b/app/assets/javascripts/web-dev-listener.js @@ -51,13 +51,13 @@ function receiveMessage(event) { } } -function create({ dom, styles, scripts }) { - virtualDom = dom; - virtualStyles = styles; - virtualScripts = scripts; - concreteDom = deku.dom.create(dom); - concreteStyles = deku.dom.create(styles); - concreteScripts = deku.dom.create(scripts); +function create(options) { + virtualDom = options.dom; + virtualStyles = options.styles; + virtualScripts = options.scripts; + concreteDom = deku.dom.create(virtualDom); + concreteStyles = deku.dom.create(virtualStyles); + concreteScripts = deku.dom.create(virtualScripts); // TODO: :after elements don't seem to work? (:before do) $('body').first().empty().append(concreteDom); replaceNodes('[for="player-styles"]', unwrapConcreteNodes(concreteStyles)); @@ -69,7 +69,7 @@ function unwrapConcreteNodes(wrappedNodes) { } function replaceNodes(selector, newNodes){ - $newNodes = $(newNodes).clone() + $newNodes = $(newNodes).clone(); $(selector + ':not(:first)').remove(); firstNode = $(selector).first(); @@ -85,7 +85,10 @@ function replaceNodes(selector, newNodes){ $(newFirstNode).after($newNodes); } -function update({ dom, styles, scripts }) { +function update(options) { + var dom = options.dom; + var styles = options.styles; + var scripts = options.scripts; function dispatch() {} // Might want to do something here in the future var context = {}; // Might want to use this to send shared state to every component @@ -152,7 +155,7 @@ function downTheChain(obj, keyChain) { keyChain = keyChain.slice(1); } return value; -}; +} function matchesCheck(value, check) { var v = downTheChain(value, check.eventProps);