Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/dominiq.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ var libxml = require('libxmljs'),
exports.createHTMLDocument = createHTMLDocument;


function createHTMLDocument(html) {
function createHTMLDocument(html, encoding) {
var doc = libxml.parseHtmlString(html);


if (encoding) doc.encoding(encoding);

return new HTMLDocument(doc);
}

Expand Down Expand Up @@ -84,8 +86,7 @@ function cloneAndImportNode(document, nodeIn) {
}

function createTextNode(document, text) {
var node = new libxml.Element(document, 'span', {}, text).childNodes()[0];

var node = new libxml.Element(document, 'span', {}, text);//.childNodes();//[0];
node.remove();

return node;
Expand Down Expand Up @@ -200,6 +201,10 @@ function HTMLElement(node) {
this.style = {};
}

HTMLElement.prototype.text = function() {
return this._n.text();
};

HTMLElement.prototype.__defineGetter__('textContent', function() {
return this._n.text();
});
Expand Down
8 changes: 6 additions & 2 deletions lib/jqresque.js
Original file line number Diff line number Diff line change
Expand Up @@ -1291,8 +1291,12 @@ exports.init = function(window) {
if ( typeof text !== "object" && text !== undefined ) {
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
}

return jQuery.text( this );
var text = '';
jQuery(this.get()).each(function(id, el) {
text+=el.textContent;
});
return text;
//jQuery.text( this );
},

wrapAll: function( html ) {
Expand Down
4 changes: 2 additions & 2 deletions lib/nquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ var Dominiq = require('./dominiq');
var Sizzle = require('./sizzle');
var jQuery = require('./jqresque');

exports.createHtmlDocument = function(html) {
var doc = Dominiq.createHTMLDocument(html);
exports.createHtmlDocument = function(html, encoding) {
var doc = Dominiq.createHTMLDocument(html, encoding);
var window = {document:doc};
var sizzle = Sizzle.init(window);
var $ = jQuery.init(window);
Expand Down