mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix ie bug with null and orphans elements
This commit is contained in:
parent
02fa10f93c
commit
2a7cd9f390
3 changed files with 21 additions and 12 deletions
|
|
@ -91,12 +91,15 @@ function extensionMap(angular, name) {
|
|||
}
|
||||
|
||||
function jqLiteWrap(element) {
|
||||
if (isString(element)) {
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = element;
|
||||
element = new JQLite(div.childNodes);
|
||||
} else if (!(element instanceof JQLite) && isElement(element)) {
|
||||
element = new JQLite(element);
|
||||
// for some reasons the parentNode of an orphan looks like null but its typeof is object.
|
||||
if (element) {
|
||||
if (isString(element)) {
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = element;
|
||||
element = new JQLite(div.childNodes);
|
||||
} else if (!(element instanceof JQLite) && isElement(element)) {
|
||||
element = new JQLite(element);
|
||||
}
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ Compiler.prototype = {
|
|||
directives = false;
|
||||
var parent = element.parent();
|
||||
template.addInit(widget.call(selfApi, element));
|
||||
if (parent) {
|
||||
if (parent && parent[0]) {
|
||||
element = jqLite(parent[0].childNodes[elementIndex]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -220,7 +220,10 @@ JQLite.prototype = {
|
|||
return this[0].innerHTML;
|
||||
},
|
||||
|
||||
parent: function() { return jqLite(this[0].parentNode);},
|
||||
parent: function() {
|
||||
return jqLite(this[0].parentNode);
|
||||
},
|
||||
|
||||
clone: function() { return jqLite(this[0].cloneNode(true)); }
|
||||
};
|
||||
|
||||
|
|
@ -228,11 +231,14 @@ if (msie) {
|
|||
extend(JQLite.prototype, {
|
||||
text: function(value) {
|
||||
var e = this[0];
|
||||
if (isDefined(value)) {
|
||||
e.innerText = value;
|
||||
}
|
||||
// NodeType == 3 is text node
|
||||
return e.nodeType == 3 ? e.nodeValue : e.innerText;
|
||||
if (e.nodeType == 3) {
|
||||
if (isDefined(value)) e.nodeValue = value;
|
||||
return e.nodeValue;
|
||||
} else {
|
||||
if (isDefined(value)) e.innerText = value;
|
||||
return e.innerText;
|
||||
}
|
||||
},
|
||||
|
||||
trigger: function(type) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue