Skip to content
This repository
  • 6 commits
  • 4 files changed
  • 0 comments
  • 2 contributors
20  functions/attachDocumentReadyListener/rendition1.js
... ...
@@ -0,0 +1,20 @@
  1
+// Degrades in IE 8- 
  2
+// No frames or other alternate windows 
  3
+// Best used with asset-light documents 
  4
+
  5
+var attachDocumentReadyListener
  6
+	readyListenerAttached;
  7
+
  8
+if(isHostMethod(global, "addEventListener")) {
  9
+	attachDocumentReadyListener = function(fn) {
  10
+		
  11
+		// Remove this "scaffolding" on deployment 
  12
+		if(readyListenerAttached) {
  13
+			throw new Error("One too many ready listeners. Use a queue!");
  14
+		}
  15
+		readyListenerAttached = true;
  16
+		
  17
+		// Production function starts (and ends) here 
  18
+		window.addEventListener('load', fn, false);
  19
+	};
  20
+};
39  functions/attachDocumentReadyListener/rendition2.js
... ...
@@ -0,0 +1,39 @@
  1
+// Degrades in IE 8- 
  2
+// No frames or other alternate windows
  3
+// Can use following to get IE8- to work when document is parsed.
  4
+//		<script type="text/javascript"> 
  5
+//			if ('function' == typeof readyListener) { 
  6
+//				window.setTimeout(readyListener, 1); 
  7
+//			} 
  8
+//		</script> 
  9
+//	</body>
  10
+
  11
+var attachDocumentReadyListener, 
  12
+	readyListener, 
  13
+	readyListenerAttached,
  14
+	documentIsReady; 
  15
+
  16
+if (isHostMethod(global, "addEventListener") && globalDocument && isHostMethod(globalDocument, "addEventListener")) { 
  17
+	attachDocumentReadyListener = function(fn) { 
  18
+
  19
+		// Remove this "scaffolding" on deployment 
  20
+		if (readyListenerAttached) { 
  21
+			throw new Error('One too many ready listeners. Use a queue!'); 
  22
+		} 
  23
+
  24
+		readyListenerAttached = true; 
  25
+
  26
+		// Production function starts here 
  27
+
  28
+		// Run on first fired event 
  29
+		readyListener = function() { 
  30
+			if (!documentIsReady) { 
  31
+				documentIsReady = true; 
  32
+				fn(); 
  33
+			} 
  34
+		}; 
  35
+
  36
+		global.addEventListener('load', readyListener, false); 
  37
+		globalDocument.addEventListener('DOMContentLoaded', readyListener, false); 
  38
+	}; 
  39
+};
18  functions/attachDocumentReadyListener/rendition3.js
... ...
@@ -0,0 +1,18 @@
  1
+// Works in IE8-
  2
+
  3
+var attachDocumentReadyListener
  4
+	readyListenerAttached;
  5
+
  6
+if(isHostMethod(global, "attachEvent")) {
  7
+	attachDocumentReadyListener = function(fn) {
  8
+		
  9
+		// Remove this "scaffolding" on deployment 
  10
+		if(readyListenerAttached) {
  11
+			throw new Error("One too many ready listeners. Use a queue!");
  12
+		}
  13
+		readyListenerAttached = true;
  14
+		
  15
+		// Production function starts (and ends) here 
  16
+		window.attachEvent('load', fn, false);
  17
+	};
  18
+};
12  functions/createXhr/rendition1.js.js
... ...
@@ -0,0 +1,12 @@
  1
+var createXhr;
  2
+	
  3
+if(isHostMethod(global, "XMLHttpRequest")) {
  4
+	try {
  5
+		if(new global.XMLHttpRequest()) {
  6
+			createXhr = function() {
  7
+				return new XMLHttpRequest();
  8
+			};
  9
+		}
  10
+	}
  11
+	catch(e) {};
  12
+};

No commit comments for this range

Something went wrong with that request. Please try again.