Skip to content

Commit

Permalink
Merge pull request #508 from alexindigo/master
Browse files Browse the repository at this point in the history
Respect options on the element level

fixes #496, #460
  • Loading branch information
fb55 committed Jun 9, 2014
2 parents 423615d + 44d8b6a commit aa886bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/api/manipulation.js
Expand Up @@ -233,9 +233,9 @@ var empty = exports.empty = function() {
var html = exports.html = function(str) {
if (str === undefined) {
if (!this[0] || !this[0].children) return null;
return $.html(this[0].children);
return $.html(this[0].children, this.options);
}

var opts = this.options;

domEach(this, function(i, el) {
Expand Down
13 changes: 13 additions & 0 deletions test/cheerio.js
Expand Up @@ -264,4 +264,17 @@ describe('cheerio', function() {
expect(dom.html({xmlMode: true})).to.be(expectedXml);
});

it('should respect options on the element level', function() {
var str = '<!doctype html><html><head><title>Some test</title></head><body><footer><p>Copyright &copy; 2003-2014</p></footer></body></html>',
expectedHtml = '<p>Copyright &copy; 2003-2014</p>',
expectedXml = '<p>Copyright &#xA9; 2003-2014</p>',
domNotEncoded = $.load(str, {decodeEntities: false}),
domEncoded = $.load(str);

expect(domNotEncoded('footer').html()).to.be(expectedHtml);
// TODO: Make it more html friendly, maybe with custom encode tables
expect(domEncoded('footer').html()).to.be(expectedXml);
});


});

0 comments on commit aa886bf

Please sign in to comment.