From 6f0def19c502e160cf4ee1e58d0454aef9005654 Mon Sep 17 00:00:00 2001 From: Tobie Langel Date: Fri, 4 Jan 2008 00:30:53 +0000 Subject: [PATCH] prototype: Add document.loaded, a boolean that is set to true once dom:loaded is fired. --- CHANGELOG | 2 ++ src/event.js | 9 +++++---- test/unit/event.html | 7 ++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 56b03cc..56700ef 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Add document.loaded, a boolean that is set to true once dom:loaded is fired. Setting document.loaded to true before the document is loaded prevents dom:loaded from being fired. [Tobie Langel] + * Make Element#insert standard-compliant. Fixes an issue in FF3b2 when inserting HTML or text inside DOM nodes which aren't (yet) appended to the document. [Tobie Langel] * Add some missing semicolons to the source tree. Closes #10659. [Richard Quadling] diff --git a/src/event.js b/src/event.js index 5fa7c18..46688da 100644 --- a/src/event.js +++ b/src/event.js @@ -276,20 +276,21 @@ Element.addMethods({ Object.extend(document, { fire: Element.Methods.fire.methodize(), observe: Element.Methods.observe.methodize(), - stopObserving: Element.Methods.stopObserving.methodize() + stopObserving: Element.Methods.stopObserving.methodize(), + loaded: false }); (function() { /* Support for the DOMContentLoaded event is based on work by Dan Webb, Matthias Miller, Dean Edwards and John Resig. */ - var timer, fired = false; + var timer; function fireContentLoadedEvent() { - if (fired) return; + if (document.loaded) return; if (timer) window.clearInterval(timer); document.fire("dom:loaded"); - fired = true; + document.loaded = true; } if (document.addEventListener) { diff --git a/test/unit/event.html b/test/unit/event.html index 8cf4074..f644f2e 100644 --- a/test/unit/event.html +++ b/test/unit/event.html @@ -31,7 +31,7 @@