working push/pop

This commit is contained in:
Adam Bradley
2015-05-13 08:54:11 -05:00
parent aa4efdd12a
commit ab2b78a99c
3 changed files with 26 additions and 15 deletions

View File

@ -152,8 +152,9 @@ export class NavBase {
this.remove(item);
i = 0;
ii = this.items.length;
debugger
item.dispose && item.dispose();
util.dom.raf(() => {
item.destroy();
});
}
}
}
@ -211,9 +212,8 @@ debugger
return this.items.length;
}
remove(index) {
const item = this.items[index];
this.items.splice(index, 1);
remove(itemOrIndex) {
util.array.remove(this.items, itemOrIndex);
}
getToolbars(pos: String) {

View File

@ -35,7 +35,6 @@ export class NavItem {
.then((componentRef) => {
this.component = componentRef;
this.dispose = componentRef._dispose;
this.domElement = componentRef.location.domElement;
this.domElement.classList.add('nav-item');
@ -55,4 +54,10 @@ export class NavItem {
return promise;
}
destroy() {
this.component && this.component._dispose && this.component._dispose();
this.domElement = this.component = this.params = this.nav = null;
}
}

View File

@ -68,12 +68,13 @@ export function defaults(dest) {
return dest;
}
export const isString = val => typeof val === 'string'
export const isFunction = val => typeof val === 'function'
export const isDefined = val => typeof val !== 'undefined'
export const isUndefined = val => typeof val === 'undefined'
export const isObject = val => typeof val === 'object'
export const isArray = Array.isArray
export const isString = val => typeof val === 'string';
export const isNumber = val => typeof val === 'number';
export const isFunction = val => typeof val === 'function';
export const isDefined = val => typeof val !== 'undefined';
export const isUndefined = val => typeof val === 'undefined';
export const isObject = val => typeof val === 'object';
export const isArray = Array.isArray;
/**
* Convert a string in the format thisIsAString to a slug format this-is-a-string
@ -113,9 +114,14 @@ export let array = {
if (cb(arr[i], i)) return arr[i];
}
},
remove(arr, item) {
const index = arr.indexOf(item);
if (index === -1) {
remove(arr, itemOrIndex) {
let index = -1;
if (isNumber(itemOrIndex)) {
index = itemOrIndex;
} else {
index = arr.indexOf(itemOrIndex);
}
if (index < 0) {
return false;
}
arr.splice(index, 1);