Upgrade to Pro — share decks privately, control downloads, hide ads and more …

YUI3 DOMReady Bug

ningzbruc
January 24, 2013

YUI3 DOMReady Bug

There's a bug in yui3 domready event

ningzbruc

January 24, 2013
Tweet

More Decks by ningzbruc

Other Decks in Technology

Transcript

  1. WTF?! • Request was blocked? • IE was even faster

    than Chrome?! • All modules were loaded! 2
  2. doScroll if (self === self.top) { window.domreadyPoll = setInterval(function() {

    try { document.documentElement.doScroll('left'); clearInterval(window.domreadyPoll); window.domreadyPoll = null; fireReady(); } catch (domNotReady) {} }, 10); } 6
  3. Fix it YUI.GlobalConfig = { modules: { // modules config

    } }; (function () { var GLOBAL_ENV = YUI.Env; if (!GLOBAL_ENV._ready) { GLOBAL_ENV._ready = function() { GLOBAL_ENV.DOMReady = true; GLOBAL_ENV.remove(YUI.config.doc, 'DOMContentLoaded', GLOBAL_ENV._ready); }; GLOBAL_ENV.add(YUI.config.doc, 'DOMContentLoaded', GLOBAL_ENV._ready); } })(); 18