From 6f1d57c5ad80232474f4da33b8121ac1eae45693 Mon Sep 17 00:00:00 2001 From: william-bishop Date: Wed, 23 Nov 2016 13:17:45 -0700 Subject: [PATCH] =?UTF-8?q?fixing=20missing=20prop(=E2=80=98outerHTML?= =?UTF-8?q?=E2=80=99)=20implementation.=E2=80=A9Added=20an=20=E2=80=98oute?= =?UTF-8?q?rHTML=E2=80=99=20case=20to=20the=20switch=20in=20the=20prop=20f?= =?UTF-8?q?unction,=20which=20wraps=20a=20clone=20of=20=20in=20a=20contain?= =?UTF-8?q?er=20element,=20and=20sets=20=20to=20that=20container's=20HTML?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/api/attributes.js | 3 +++ test/cheerio.js | 9 +++++++++ 2 files changed, 12 insertions(+) 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); + }); + }); }); });