Skip to content

Commit 7b65de4

Browse files
committed
use native Object.create
1 parent d2eb1c7 commit 7b65de4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/jquery.inherit/jquery.inherit.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
* http://www.opensource.org/licenses/mit-license.php
77
* http://www.gnu.org/licenses/gpl.html
88
*
9-
* @version 1.3.3
9+
* @version 1.3.4
1010
*/
1111

1212
(function($) {
1313

1414
var hasIntrospection = (function(){_}).toString().indexOf('_') > -1,
1515
needCheckProps = $.browser.msie, // fucking ie hasn't toString, valueOf in for
1616
specProps = needCheckProps? ['toString', 'valueOf'] : null,
17-
emptyBase = function() {};
17+
emptyBase = function() {},
18+
objCreate = Object.create || function(ptp) {
19+
var inheritance = function() {};
20+
inheritance.prototype = ptp;
21+
return new inheritance();
22+
};
1823

1924
function override(base, result, add) {
2025

@@ -84,9 +89,8 @@ $.inherit = function() {
8489

8590
$.extend(result, base);
8691

87-
var inheritance = function() {},
88-
basePtp = inheritance.prototype = base.prototype,
89-
resultPtp = result.prototype = new inheritance();
92+
var basePtp = base.prototype,
93+
resultPtp = result.prototype = objCreate(basePtp);
9094

9195
resultPtp.__self = resultPtp.constructor = result;
9296

0 commit comments

Comments
 (0)