Skip to content

Commit

Permalink
feat(prop): Support prop('innerHTML') (#1578)
Browse files Browse the repository at this point in the history
Fixes #1099
  • Loading branch information
fb55 authored Dec 22, 2020
1 parent f386975 commit c58258f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/api/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ exports.prop = function (name, value) {
case 'outerHTML':
property = this.clone().wrap('<container />').parent().html();
break;
case 'innerHTML':
property = this.html();
break;
default:
property = getProp(this[0], name);
}
Expand Down
6 changes: 6 additions & 0 deletions test/api/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,12 @@ describe('$(...)', function () {
expect($a.prop('outerHTML')).to.be(outerHtml);
});

it('("innerHTML") : should render properly', function () {
var $a = $('<div><a></a></div>');

expect($a.prop('innerHTML')).to.be('<a></a>');
});

it('(inherited properties) : prop should support inherited properties', function () {
expect(selectMenu.prop('childNodes')).to.equal(selectMenu[0].childNodes);
});
Expand Down

0 comments on commit c58258f

Please sign in to comment.