Skip to content

Commit

Permalink
Fix issue #222
Browse files Browse the repository at this point in the history
- Replace for of by forEach to support ie11. For of output Symbol on
babel compilation result.
  • Loading branch information
fkhadra committed Aug 22, 2018
1 parent 85caa85 commit 2c06db6
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 20 deletions.
4 changes: 2 additions & 2 deletions dist/ReactToastify.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ReactToastify.js.map

Large diffs are not rendered by default.

94 changes: 86 additions & 8 deletions src/__tests__/components/__snapshots__/ProgressBar.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@

exports[`ProgressBar Should be able to hide the progress bar 1`] = `
ShallowWrapper {
"length": 1,
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <ProgressBar
closeToast={[Function]}
closeToast={
[MockFunction] {
"calls": Array [
Array [],
],
"results": Array [
Object {
"isThrow": false,
"value": undefined,
},
],
}
}
delay={5000}
hide={true}
isRunning={true}
Expand All @@ -25,7 +36,17 @@ ShallowWrapper {
"nodeType": "host",
"props": Object {
"className": "Toastify__progress-bar Toastify__progress-bar--default",
"onAnimationEnd": [Function],
"onAnimationEnd": [MockFunction] {
"calls": Array [
Array [],
],
"results": Array [
Object {
"isThrow": false,
"value": undefined,
},
],
},
"style": Object {
"animationDuration": "5000ms",
"animationPlayState": "running",
Expand All @@ -43,7 +64,17 @@ ShallowWrapper {
"nodeType": "host",
"props": Object {
"className": "Toastify__progress-bar Toastify__progress-bar--default",
"onAnimationEnd": [Function],
"onAnimationEnd": [MockFunction] {
"calls": Array [
Array [],
],
"results": Array [
Object {
"isThrow": false,
"value": undefined,
},
],
},
"style": Object {
"animationDuration": "5000ms",
"animationPlayState": "running",
Expand All @@ -59,18 +90,37 @@ ShallowWrapper {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getSnapshotBeforeUpdate": true,
},
},
},
"attachTo": undefined,
"hydrateIn": undefined,
},
}
`;

exports[`ProgressBar Should be able to pause animation 1`] = `
ShallowWrapper {
"length": 1,
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <ProgressBar
closeToast={[Function]}
closeToast={
[MockFunction] {
"calls": Array [
Array [],
],
"results": Array [
Object {
"isThrow": false,
"value": undefined,
},
],
}
}
delay={5000}
hide={false}
isRunning={false}
Expand All @@ -90,7 +140,17 @@ ShallowWrapper {
"nodeType": "host",
"props": Object {
"className": "Toastify__progress-bar Toastify__progress-bar--default",
"onAnimationEnd": [Function],
"onAnimationEnd": [MockFunction] {
"calls": Array [
Array [],
],
"results": Array [
Object {
"isThrow": false,
"value": undefined,
},
],
},
"style": Object {
"animationDuration": "5000ms",
"animationPlayState": "paused",
Expand All @@ -108,7 +168,17 @@ ShallowWrapper {
"nodeType": "host",
"props": Object {
"className": "Toastify__progress-bar Toastify__progress-bar--default",
"onAnimationEnd": [Function],
"onAnimationEnd": [MockFunction] {
"calls": Array [
Array [],
],
"results": Array [
Object {
"isThrow": false,
"value": undefined,
},
],
},
"style": Object {
"animationDuration": "5000ms",
"animationPlayState": "paused",
Expand All @@ -124,8 +194,16 @@ ShallowWrapper {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getSnapshotBeforeUpdate": true,
},
},
},
"attachTo": undefined,
"hydrateIn": undefined,
},
}
`;
9 changes: 8 additions & 1 deletion src/__tests__/components/__snapshots__/Toast.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

exports[`Toast Should support Rtl display 1`] = `
ShallowWrapper {
"length": 1,
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <Toast
autoClose={false}
Expand Down Expand Up @@ -219,8 +218,16 @@ ShallowWrapper {
"adapter": ReactSixteenAdapter {
"options": Object {
"enableComponentDidUpdateOnSetState": true,
"lifecycles": Object {
"componentDidUpdate": Object {
"onSetState": true,
},
"getSnapshotBeforeUpdate": true,
},
},
},
"attachTo": undefined,
"hydrateIn": undefined,
},
}
`;
4 changes: 2 additions & 2 deletions src/components/ToastContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class ToastContainer extends Component {
: Object.keys(this.collection);

// group toast by position
for (const toastId of collection) {
collection.forEach(toastId => {
const toast = this.collection[toastId];
toastToRender[toast.position] || (toastToRender[toast.position] = []);

Expand All @@ -350,7 +350,7 @@ class ToastContainer extends Component {
toastToRender[toast.position].push(null);
delete this.collection[toastId];
}
}
})

return Object.keys(toastToRender).map(position => {
const disablePointer =
Expand Down
4 changes: 2 additions & 2 deletions src/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ eventManager
container = containerInstance;
toast.isActive = id => container.isToastActive(id);

for (const item of queue) {
queue.forEach(item => {
eventManager.emit(item.action, item.content, item.options);
}
});

queue = [];
})
Expand Down
7 changes: 3 additions & 4 deletions src/utils/eventManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ const eventManager = {
if (!this.list.has(event)) {
return false;
}

for (const callback of this.list.get(event)) {
setTimeout(() => callback.call(this, ...args), 0);
}
this.list
.get(event)
.forEach(callback => setTimeout(() => callback.call(null, ...args), 0));

return true;
}
Expand Down

0 comments on commit 2c06db6

Please sign in to comment.