Skip to content

Commit

Permalink
fix(ie) replace indexOf function array, #92
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 committed Mar 2, 2015
1 parent deefd96 commit 1360fbe
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

---

## 1.5.1

`fixed` #92 修复 IE 低版本的 indexOf 的兼容问题。

## 1.5.0

`new` #91 使用 arale-messenger 进行跨域支持。[演示](./examples/cross-domain-iframe.html)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "arale-dialog",
"version": "1.5.0",
"version": "1.5.1",
"description": "Dialog 是通用对话框容器,提供显隐关闭、遮罩层、内嵌iframe、内容区域自定义以及模态对话框等功能。",
"keywords": [
"widget",
Expand Down
17 changes: 15 additions & 2 deletions src/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ var Dialog = Overlay.extend({
}
if (existed) {
// 把已存在的对话框提到最后一个
mask._dialogs.splice(mask._dialogs.indexOf(existed), 1);
erase(existed, mask._dialogs);
mask._dialogs.push(existed);
} else {
// 存放新的对话框
Expand All @@ -276,7 +276,7 @@ var Dialog = Overlay.extend({
var dialogLength = mask._dialogs.length;
for (var i=0; i<dialogLength; i++) {
if (mask._dialogs[i] === this) {
mask._dialogs.splice(mask._dialogs.indexOf(this), 1);
erase(this, mask._dialogs);

// 如果 _dialogs 为空了,表示没有打开的 dialog 了
// 则隐藏 mask
Expand Down Expand Up @@ -486,3 +486,16 @@ function isCrossDomainIframe(iframe) {
}
return isCrossDomain;
}

// erase item from array
function erase(item, array) {
var index = -1;
for (var i=0; i<array.length; i++) {
if (array[i] === item) {
index = i;
}
}
if (index !== -1) {
array.splice(array.indexOf(item), 1);
}
}

0 comments on commit 1360fbe

Please sign in to comment.