From c58258ffdc5d789c47db095bf57cb371e02a1551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20B=C3=B6hm?= Date: Tue, 22 Dec 2020 18:32:45 +0100 Subject: [PATCH] feat(prop): Support `prop('innerHTML')` (#1578) Fixes #1099 --- lib/api/attributes.js | 3 +++ test/api/attributes.js | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lib/api/attributes.js b/lib/api/attributes.js index be0b889b1a..96e0795c66 100644 --- a/lib/api/attributes.js +++ b/lib/api/attributes.js @@ -163,6 +163,9 @@ exports.prop = function (name, value) { case 'outerHTML': property = this.clone().wrap('').parent().html(); break; + case 'innerHTML': + property = this.html(); + break; default: property = getProp(this[0], name); } diff --git a/test/api/attributes.js b/test/api/attributes.js index 6f338fe5f2..6ef8ce0f45 100644 --- a/test/api/attributes.js +++ b/test/api/attributes.js @@ -206,6 +206,12 @@ describe('$(...)', function () { expect($a.prop('outerHTML')).to.be(outerHtml); }); + it('("innerHTML") : should render properly', function () { + var $a = $('
'); + + expect($a.prop('innerHTML')).to.be(''); + }); + it('(inherited properties) : prop should support inherited properties', function () { expect(selectMenu.prop('childNodes')).to.equal(selectMenu[0].childNodes); });