Skip to content

Commit

Permalink
Expose window and added option to change behaviour outlined in node-j…
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Oct 5, 2011
1 parent bb61109 commit d3f7039
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/node.io/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Job.prototype.$ = function (selector, context, suppressErrors) {
selected = false;
else
throw new Error("No elements matching '" + selector + "'");
} else if (selected.length === 1) {
} else if (selected.length === 1 && this.options.expand_single_selected) {
selected = selected[0];
this.bindToDomElement(selected);
} else {
Expand All @@ -54,11 +54,11 @@ Job.prototype.parseHtml = function (data, callback, response) {
ProcessExternalResources: this.options.external_resources,
QuerySelector: false
};
var $, window, jquery, default_$;
var $, jquery, default_$;
try {
window = require('jsdom').jsdom(data, null, {features:features, url:response.url}).createWindow();
this.window = require('jsdom').jsdom(data, null, {features:features, url:response.url}).createWindow();
jquery = require('jquery');
default_$ = jquery.create(window);
default_$ = jquery.create(this.window);
$ = function (selector, context) {
return context ? jquery.create(context)(selector) : default_$(selector);
};
Expand Down
3 changes: 2 additions & 1 deletion lib/node.io/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ var default_options = {
jsdom: false,
auto_retry: false,
ignore_code: false,
external_resources: false
external_resources: false,
expand_single_selected: true
};

/**
Expand Down

0 comments on commit d3f7039

Please sign in to comment.