Permalink
Browse files

fixed up jsdom.jQueryify to take a window, fixed jQuery example to us…

…e it. all was well
  • Loading branch information...
1 parent 77275a8 commit 576aff885fbc80687d1df0e98aac76b0e205f8ed @tmpvar committed Aug 12, 2010
Showing with 7 additions and 18 deletions.
  1. +6 −15 example/jquery/run.js
  2. +1 −3 lib/jsdom.js
View
@@ -1,21 +1,12 @@
var sys = require("sys"),
- jsdom = require(__dirname + "/../../lib/jsdom").jsdom,
- window = jsdom().createWindow(),
+ jsdom = require(__dirname + "/../../lib/jsdom"),
+ window = jsdom.jsdom().createWindow(),
head = window.document.getElementsByTagName('head')[0],
jQueryTag = window.document.createElement("script");
-jQueryTag.src = "file://" + __dirname + "/jquery.js";
-
// this also works:
// jQueryTag.src = "http://code.jquery.com/jquery-1.4.2.js";
-
-head.appendChild(jQueryTag);
-
-jQueryTag.onload = function() {
- if (this.readyState === 'complete') {
- // jQuery is ready!
- window.jQuery('body').append("<div class='testing'>Hello World, It works!</div>");
- sys.puts(window.jQuery(".testing").text());
- }
-};
-
+jsdom.jQueryify(window, __dirname + "/jquery.js", function() {
+ window.jQuery('body').append("<div class='testing'>Hello World, It works!</div>");
+ sys.puts(window.jQuery(".testing").text());
+});
View
@@ -21,9 +21,7 @@ exports.createWindow = function (html, level) {
return window;
};
-exports.jQueryify = function (html, level, path, fn) {
- var window = exports.createWindow(html, level);
-
+exports.jQueryify = function (window, path, fn) {
var head = window.document.getElementsByTagName('head')[0],
jQueryTag = window.document.createElement("script");

0 comments on commit 576aff8

Please sign in to comment.