2009/dap/ReSpec.js/js respec.js,1.62,1.63

Update of /sources/public/2009/dap/ReSpec.js/js
In directory hutz:/tmp/cvs-serv11172/js

Modified Files:
	respec.js 
Log Message:
make CSS inlining synchronous

Index: respec.js
===================================================================
RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- respec.js	4 Dec 2009 13:47:49 -0000	1.62
+++ respec.js	4 Dec 2009 13:53:47 -0000	1.63
@@ -761,19 +761,27 @@
         // if (document.createStyleSheet) return document.createStyleSheet(css);
         if (inlined) {
             try {
+                // this is synchronous because order of the CSS matters (if though PubRules doesn't detect this
+                // correctly :-) If it's slow, turn off inlineCSS during development
                 var xhr = new XMLHttpRequest();
-                xhr.open("GET", css);
-                xhr.onreadystatechange = function () {
-                    if (this.readyState == 4) {
-                        if (this.status == 200) {
-                            sn.element("style", { type: "text/css" }, document.documentElement.firstElementChild, this.responseText);
-                        }
-                        else {
-                            error("There appear to have been a problem fetching the style sheet; status=" + this.status);
-                        }
-                    }
-                };
-                xhr.send();
+                xhr.open("GET", css, false);
+                // xhr.onreadystatechange = function () {
+                //     if (this.readyState == 4) {
+                //         if (this.status == 200) {
+                //             sn.element("style", { type: "text/css" }, document.documentElement.firstElementChild, this.responseText);
+                //         }
+                //         else {
+                //             error("There appear to have been a problem fetching the style sheet; status=" + this.status);
+                //         }
+                //     }
+                // };
+                xhr.send(null);
+                if (xhr.status == 200) {
+                    sn.element("style", { type: "text/css" }, document.documentElement.firstElementChild, this.responseText);
+                }
+                else {
+                    error("There appear to have been a problem fetching the style sheet; status=" + this.status);
+                }
             }
             catch (e) {
                 // warning("There was an error with the request, probably that you're working from disk.");

Received on Friday, 4 December 2009 13:53:51 UTC