diff --git a/lib/api/manipulation.js b/lib/api/manipulation.js index 7b5a59aefe..5f999dc588 100644 --- a/lib/api/manipulation.js +++ b/lib/api/manipulation.js @@ -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) { diff --git a/test/cheerio.js b/test/cheerio.js index 7616b6447a..2673259118 100644 --- a/test/cheerio.js +++ b/test/cheerio.js @@ -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 = 'Some test', + expectedHtml = '

Copyright © 2003-2014

', + expectedXml = '

Copyright © 2003-2014

', + 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); + }); + + });