From b5f03baba8f8a74ddc2be6dfe18ad88877ab15f5 Mon Sep 17 00:00:00 2001 From: Luke Bayes Date: Mon, 17 Apr 2017 17:28:42 -0400 Subject: [PATCH] Fixed example client initialization --- examples/client/client.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/examples/client/client.js b/examples/client/client.js index be45f7d..a940204 100644 --- a/examples/client/client.js +++ b/examples/client/client.js @@ -1,4 +1,5 @@ const dom = require('../../').dom; +const ready = require('../../').ready; const renderElement = require('../../').renderElement; const DOM_CONTENT_LOADED = 'DOMContentLoaded'; @@ -7,17 +8,12 @@ function client(doc) { // Render the application immediately. This can begin before the DOM is fully ready. const app = renderElement(dom.h1('HELLO WORLD 34343'), doc); - function contentLoadedHandler() { + ready(doc, () => { // Get the element where we will attach the application. const context = doc.getElementById('context'); // Attach the application. context.appendChild(app); - // Clean up this dangling listener. - doc.removeEventListener(DOM_CONTENT_LOADED, contentLoadedHandler); - }; - - // Wait until the DOM is ready (works in IE9+ and all others?) - doc.addEventListener(DOM_CONTENT_LOADED, contentLoadedHandler); + }); } module.exports = client;