Skip to content

Commit c58258f

Browse files
authored
feat(prop): Support prop('innerHTML') (#1578)
Fixes #1099
1 parent f386975 commit c58258f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/api/attributes.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,9 @@ exports.prop = function (name, value) {
163163
case 'outerHTML':
164164
property = this.clone().wrap('<container />').parent().html();
165165
break;
166+
case 'innerHTML':
167+
property = this.html();
168+
break;
166169
default:
167170
property = getProp(this[0], name);
168171
}

test/api/attributes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ describe('$(...)', function () {
206206
expect($a.prop('outerHTML')).to.be(outerHtml);
207207
});
208208

209+
it('("innerHTML") : should render properly', function () {
210+
var $a = $('<div><a></a></div>');
211+
212+
expect($a.prop('innerHTML')).to.be('<a></a>');
213+
});
214+
209215
it('(inherited properties) : prop should support inherited properties', function () {
210216
expect(selectMenu.prop('childNodes')).to.equal(selectMenu[0].childNodes);
211217
});

0 commit comments

Comments
 (0)