mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
jqLite should recognize window as an element even in IE
in IE window object has length property which makes it look like a collection to jqLite. This commit makes jqLite properly identify window as an element even in IE. IE6 doesn't have Window type, so we need to check against window object and only then do a more general check against Window. This is not perfect, but I say screw IE6.
This commit is contained in:
parent
e999740044
commit
84dedb81e7
2 changed files with 12 additions and 1 deletions
|
|
@ -400,6 +400,17 @@ function isArray(value) { return value instanceof Array; }
|
|||
function isFunction(value){ return typeof value == $function;}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if `obj` is a window object.
|
||||
*
|
||||
* @private
|
||||
* @param {*} obj Object to check
|
||||
* @returns {boolean} True if `obj` is a window obj.
|
||||
*/
|
||||
function isWindow(obj) {
|
||||
return obj && obj.document && obj.location && obj.alert && obj.setInterval;
|
||||
}
|
||||
|
||||
function isBoolean(value) { return typeof value == $boolean;}
|
||||
function isTextNode(node) { return nodeName_(node) == '#text'; }
|
||||
function trim(value) { return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value; }
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ function getStyle(element) {
|
|||
}
|
||||
|
||||
function JQLite(element) {
|
||||
if (!isElement(element) && isDefined(element.length) && element.item) {
|
||||
if (!isElement(element) && isDefined(element.length) && element.item && !isWindow(element)) {
|
||||
for(var i=0; i < element.length; i++) {
|
||||
this[i] = element[i];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue