Skip to content

Commit

Permalink
修复IE6-8下动态生成tr元素时,浏览器私自插入caption元素,导致locateFragment方法计算出错的BUG fix Rub…
Browse files Browse the repository at this point in the history
  • Loading branch information
qincheng committed Nov 17, 2014
1 parent 47c2167 commit b375083
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 13 deletions.
10 changes: 9 additions & 1 deletion avalon.js
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@
for (i = wrap[0]; i--; wrapper = wrapper.lastChild) {
}
if (!W3C) { //fix IE
for (els = wrapper["getElementsByTagName"]("br"), i = 0; el = els[i++]; ) {
for (els = avalon.slice(wrapper["getElementsByTagName"]("br")), i = 0; el = els[i++]; ) {
if (el.className && el.className === "msNoScope") {
el.parentNode.removeChild(el)
}
Expand All @@ -1704,6 +1704,14 @@
fixVML(el)
}
}
if (tag === "tr") {
for (els = avalon.slice(wrapper.children), i = 0; el = els[i++]; ) {
// IE6-8,如果动态生成tr元素,必须会在后面添加早已废弃caption的标签,其nodeName,innerHTML都为""
if (el.nodeName == "") {
el.parentNode.removeChild(el)
}
}
}
}
while (firstChild = wrapper.firstChild) { // 将wrapper上的节点转移到文档碎片上!
fragment.appendChild(firstChild)
Expand Down
23 changes: 12 additions & 11 deletions avalon.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion examples/avalon.shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,7 @@
for (i = wrap[0]; i--; wrapper = wrapper.lastChild) {
}
if (!W3C) { //fix IE
for (els = wrapper["getElementsByTagName"]("br"), i = 0; el = els[i++]; ) {
for (els = avalon.slice(wrapper["getElementsByTagName"]("br")), i = 0; el = els[i++]; ) {
if (el.className && el.className === "msNoScope") {
el.parentNode.removeChild(el)
}
Expand All @@ -1704,6 +1704,14 @@
fixVML(el)
}
}
if (tag === "tr") {
for (els = avalon.slice(wrapper.children), i = 0; el = els[i++]; ) {
// IE6-8,如果动态生成tr元素,必须会在后面添加早已废弃caption的标签,其nodeName,innerHTML都为""
if (el.nodeName == "") {
el.parentNode.removeChild(el)
}
}
}
}
while (firstChild = wrapper.firstChild) { // 将wrapper上的节点转移到文档碎片上!
fragment.appendChild(firstChild)
Expand Down

0 comments on commit b375083

Please sign in to comment.