ES5ify web-dev-listener.js

This commit is contained in:
Nick Winter 2016-08-03 13:02:55 -07:00
parent ba6d51659c
commit 35966b24c1

View file

@ -51,13 +51,13 @@ function receiveMessage(event) {
} }
} }
function create({ dom, styles, scripts }) { function create(options) {
virtualDom = dom; virtualDom = options.dom;
virtualStyles = styles; virtualStyles = options.styles;
virtualScripts = scripts; virtualScripts = options.scripts;
concreteDom = deku.dom.create(dom); concreteDom = deku.dom.create(virtualDom);
concreteStyles = deku.dom.create(styles); concreteStyles = deku.dom.create(virtualStyles);
concreteScripts = deku.dom.create(scripts); concreteScripts = deku.dom.create(virtualScripts);
// TODO: :after elements don't seem to work? (:before do) // TODO: :after elements don't seem to work? (:before do)
$('body').first().empty().append(concreteDom); $('body').first().empty().append(concreteDom);
replaceNodes('[for="player-styles"]', unwrapConcreteNodes(concreteStyles)); replaceNodes('[for="player-styles"]', unwrapConcreteNodes(concreteStyles));
@ -69,7 +69,7 @@ function unwrapConcreteNodes(wrappedNodes) {
} }
function replaceNodes(selector, newNodes){ function replaceNodes(selector, newNodes){
$newNodes = $(newNodes).clone() $newNodes = $(newNodes).clone();
$(selector + ':not(:first)').remove(); $(selector + ':not(:first)').remove();
firstNode = $(selector).first(); firstNode = $(selector).first();
@ -85,7 +85,10 @@ function replaceNodes(selector, newNodes){
$(newFirstNode).after($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 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 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); keyChain = keyChain.slice(1);
} }
return value; return value;
}; }
function matchesCheck(value, check) { function matchesCheck(value, check) {
var v = downTheChain(value, check.eventProps); var v = downTheChain(value, check.eventProps);