Merge pull request #6006 from driftyco/strict-mode-fn-fix

chore(): move nested functions out of if blocks
This commit is contained in:
Adam Bradley
2016-03-31 16:03:24 -05:00

View File

@ -91,25 +91,25 @@ export let CSS: {
export function transitionEnd(el: HTMLElement, callback: Function) { export function transitionEnd(el: HTMLElement, callback: Function) {
if (el) { if (el) {
function unregister() {
CSS.transitionEnd.split(' ').forEach(eventName => {
el.removeEventListener(eventName, onEvent);
});
}
function onEvent(ev) {
if (el === ev.target) {
unregister();
callback(ev);
}
}
CSS.transitionEnd.split(' ').forEach(eventName => { CSS.transitionEnd.split(' ').forEach(eventName => {
el.addEventListener(eventName, onEvent); el.addEventListener(eventName, onEvent);
}); });
return unregister; return unregister;
} }
function unregister() {
CSS.transitionEnd.split(' ').forEach(eventName => {
el.removeEventListener(eventName, onEvent);
});
}
function onEvent(ev) {
if (el === ev.target) {
unregister();
callback(ev);
}
}
} }
export function ready(callback?: Function) { export function ready(callback?: Function) {
@ -124,17 +124,17 @@ export function ready(callback?: Function) {
callback(); callback();
} else { } else {
function completed() {
document.removeEventListener('DOMContentLoaded', completed, false);
window.removeEventListener('load', completed, false);
callback();
}
document.addEventListener('DOMContentLoaded', completed, false); document.addEventListener('DOMContentLoaded', completed, false);
window.addEventListener('load', completed, false); window.addEventListener('load', completed, false);
} }
return promise; return promise;
function completed() {
document.removeEventListener('DOMContentLoaded', completed, false);
window.removeEventListener('load', completed, false);
callback();
}
} }
export function windowLoad(callback?: Function) { export function windowLoad(callback?: Function) {
@ -149,15 +149,16 @@ export function windowLoad(callback?: Function) {
callback(); callback();
} else { } else {
function completed() {
window.removeEventListener('load', completed, false);
callback();
}
window.addEventListener('load', completed, false); window.addEventListener('load', completed, false);
} }
return promise; return promise;
function completed() {
window.removeEventListener('load', completed, false);
callback();
}
} }
export function pointerCoord(ev: any): {x: number, y: number} { export function pointerCoord(ev: any): {x: number, y: number} {