Merge pull request #733 from laurentj/issue-732
Fixed betterInstanceOf for Gecko
Showing
1 changed file
with
11 additions
and
7 deletions
... | @@ -81,19 +81,23 @@ exports.betterTypeOf = betterTypeOf; | ... | @@ -81,19 +81,23 @@ exports.betterTypeOf = betterTypeOf; |
81 | function betterInstanceOf(input, constructor) { | 81 | function betterInstanceOf(input, constructor) { |
82 | "use strict"; | 82 | "use strict"; |
83 | /*jshint eqnull:true, eqeqeq:false */ | 83 | /*jshint eqnull:true, eqeqeq:false */ |
84 | while (input != null) { | 84 | if (typeof input == 'undefined' || input == null) { |
85 | if (input == constructor.prototype) { | 85 | return false; |
86 | } | ||
87 | var inputToTest = input; | ||
88 | while (inputToTest != null) { | ||
89 | if (inputToTest == constructor.prototype) { | ||
86 | return true; | 90 | return true; |
87 | } | 91 | } |
88 | if (typeof input == 'xml') { | 92 | if (typeof inputToTest == 'xml') { |
89 | return constructor.prototype == document.prototype; | 93 | return constructor.prototype == document.prototype; |
90 | } | 94 | } |
91 | if (typeof input == 'undefined') { | 95 | if (typeof inputToTest == 'undefined') { |
92 | return false; | 96 | return false; |
93 | } | 97 | } |
94 | input = input.__proto__; | 98 | inputToTest = inputToTest.__proto__; |
95 | } | 99 | } |
96 | return false; | 100 | return equals(input.constructor.name, constructor.name); |
97 | } | 101 | } |
98 | exports.betterInstanceOf = betterInstanceOf; | 102 | exports.betterInstanceOf = betterInstanceOf; |
99 | 103 | ... | ... |
-
Please register or sign in to post a comment