Permalink
Browse files

added jsdom.html() method which is the same as jsdom but it ensures t…

…here is an html/body tag wrapping the incomming markup
  • Loading branch information...
1 parent 4ff0ce2 commit b7ee0f3290a32586babc7b287295b7ca498f5477 @tmpvar tmpvar committed Feb 5, 2011
Showing with 13 additions and 0 deletions.
  1. +13 −0 lib/jsdom.js
View
@@ -54,6 +54,19 @@ exports.jsdom = function (html, level, options) {
return doc;
};
+exports.html = function(html, level, options) {
+ // body
+ if (!~html.indexOf('<body')) {
+ html = '<body>' + html + '</body>';
+ }
+
+ // html
+ if (!~html.indexOf('<html')) {
+ html = '<html>' + html + '</html>';
+ }
+ return exports.jsdom(html, level, options);
+}
+
exports.availableDocumentFeatures = [
'FetchExternalResources',
'ProcessExternalResources',

0 comments on commit b7ee0f3

Please sign in to comment.