diff --git a/lib/api/attributes.js b/lib/api/attributes.js index 9a22d44e24..58c988b59b 100644 --- a/lib/api/attributes.js +++ b/lib/api/attributes.js @@ -125,6 +125,9 @@ exports.prop = function (name, value) { case 'nodeName': property = this[0].name.toUpperCase(); break; + case 'outerHTML': + property = this.clone().wrap('').parent().html(); + break; default: property = getProp(this[0], name); } diff --git a/test/cheerio.js b/test/cheerio.js index a119b749ce..1877bb2098 100644 --- a/test/cheerio.js +++ b/test/cheerio.js @@ -350,5 +350,14 @@ describe('cheerio', function() { expect($b('div').foo).to.be(undefined); }); }); + + describe('.prop', function () { + describe('("outerHTML")', function () { + var outerHtml = '
'; + var $a = $(outerHtml); + + expect($a.prop('outerHTML')).to.be(outerHtml); + }); + }); }); });