@endorphinjs/template-runtime
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -1,10 +0,12 @@ | ||
import { Component } from './component'; | ||
import { Scope } from './types'; | ||
declare type AnimationCallback = (elem: Element, scope?: Scope) => void; | ||
/** | ||
* Animates element appearance | ||
*/ | ||
export declare function animateIn(elem: HTMLElement | Component, animation: string, cssScope?: string): void; | ||
export declare function animateIn(elem: HTMLElement, animation: string, cssScope?: string): void; | ||
/** | ||
* Animates element disappearance | ||
*/ | ||
export declare function animateOut(elem: HTMLElement | Component, animation: string, cssScope: string): void; | ||
export declare function animateOut<T>(elem: HTMLElement | Component, animation: string, scope: T, callback: (scope: T) => void, cssScope: string): void; | ||
export declare function animateOut(elem: HTMLElement, animation: string, cssScope: string): void; | ||
export declare function animateOut(elem: HTMLElement, animation: string, scope: Scope, callback: AnimationCallback, cssScope: string): void; | ||
export {}; |
@@ -170,3 +170,3 @@ import { Injector, BaseBlock } from './injector'; | ||
*/ | ||
export declare function updateComponent(component: Component): void; | ||
export declare function updateComponent(component: Component): number; | ||
/** | ||
@@ -173,0 +173,0 @@ * Destroys given component: removes static event listeners and cleans things up |
@@ -938,2 +938,3 @@ 'use strict'; | ||
} | ||
return changes ? 1 : 0; | ||
} | ||
@@ -1691,3 +1692,3 @@ /** | ||
elem.removeEventListener('animationcancel', handler); | ||
dispose(elem, () => callback && callback(scope)); | ||
dispose(elem, scope, callback); | ||
} | ||
@@ -1701,3 +1702,3 @@ }; | ||
else { | ||
dispose(elem, () => callback && callback(scope)); | ||
dispose(elem, scope, callback); | ||
} | ||
@@ -1733,9 +1734,4 @@ } | ||
} | ||
function dispose(elem, callback) { | ||
if ('componentModel' in elem) { | ||
unmountComponent(elem); | ||
} | ||
if (callback) { | ||
callback(); | ||
} | ||
function dispose(elem, scope, callback) { | ||
callback && callback(elem, scope); | ||
domRemove(elem); | ||
@@ -1790,7 +1786,7 @@ } | ||
*/ | ||
function filter(host, collection, fn) { | ||
function filter(collection, fn) { | ||
const result = []; | ||
if (collection && collection.forEach) { | ||
collection.forEach((value, key) => { | ||
if (fn(host, value, key)) { | ||
if (fn(value, key)) { | ||
result.push(value); | ||
@@ -1805,3 +1801,3 @@ } | ||
*/ | ||
function find(host, collection, fn) { | ||
function find(collection, fn) { | ||
if (Array.isArray(collection)) { | ||
@@ -1811,3 +1807,3 @@ // Fast path: find item in array | ||
item = collection[i]; | ||
if (fn(host, item, i)) { | ||
if (fn(item, i)) { | ||
return item; | ||
@@ -1822,3 +1818,3 @@ } | ||
collection.forEach((value, key) => { | ||
if (!found && fn(host, value, key)) { | ||
if (!found && fn(value, key)) { | ||
found = true; | ||
@@ -1825,0 +1821,0 @@ result = value; |
@@ -19,3 +19,3 @@ import { Component, ComponentDefinition } from './component'; | ||
export { addDisposeCallback, assign } from './utils'; | ||
declare type FilterCallback<T> = (host: Component, value: T, key: string | number) => boolean; | ||
declare type FilterCallback<T> = (value: T, key: string | number) => boolean; | ||
interface ComponentOptions { | ||
@@ -50,6 +50,6 @@ /** Parent element where created component should be mounted */ | ||
*/ | ||
export declare function filter<T>(host: Component, collection: T[], fn: FilterCallback<T>): T[]; | ||
export declare function filter<T>(collection: T[], fn: FilterCallback<T>): T[]; | ||
/** | ||
* Finds first item in given `collection` that matches truth test of `fn` | ||
*/ | ||
export declare function find<T>(host: Component, collection: T[] | Map<any, T> | Set<T>, fn: FilterCallback<T>): T | null | undefined; | ||
export declare function find<T>(collection: T[] | Map<any, T> | Set<T>, fn: FilterCallback<T>): T | null | undefined; |
@@ -934,2 +934,3 @@ /** | ||
} | ||
return changes ? 1 : 0; | ||
} | ||
@@ -1687,3 +1688,3 @@ /** | ||
elem.removeEventListener('animationcancel', handler); | ||
dispose(elem, () => callback && callback(scope)); | ||
dispose(elem, scope, callback); | ||
} | ||
@@ -1697,3 +1698,3 @@ }; | ||
else { | ||
dispose(elem, () => callback && callback(scope)); | ||
dispose(elem, scope, callback); | ||
} | ||
@@ -1729,9 +1730,4 @@ } | ||
} | ||
function dispose(elem, callback) { | ||
if ('componentModel' in elem) { | ||
unmountComponent(elem); | ||
} | ||
if (callback) { | ||
callback(); | ||
} | ||
function dispose(elem, scope, callback) { | ||
callback && callback(elem, scope); | ||
domRemove(elem); | ||
@@ -1786,7 +1782,7 @@ } | ||
*/ | ||
function filter(host, collection, fn) { | ||
function filter(collection, fn) { | ||
const result = []; | ||
if (collection && collection.forEach) { | ||
collection.forEach((value, key) => { | ||
if (fn(host, value, key)) { | ||
if (fn(value, key)) { | ||
result.push(value); | ||
@@ -1801,3 +1797,3 @@ } | ||
*/ | ||
function find(host, collection, fn) { | ||
function find(collection, fn) { | ||
if (Array.isArray(collection)) { | ||
@@ -1807,3 +1803,3 @@ // Fast path: find item in array | ||
item = collection[i]; | ||
if (fn(host, item, i)) { | ||
if (fn(item, i)) { | ||
return item; | ||
@@ -1818,3 +1814,3 @@ } | ||
collection.forEach((value, key) => { | ||
if (!found && fn(host, value, key)) { | ||
if (!found && fn(value, key)) { | ||
found = true; | ||
@@ -1821,0 +1817,0 @@ result = value; |
{ | ||
"name": "@endorphinjs/template-runtime", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "EndorphinJS template runtime, embedded with template bundles", | ||
@@ -25,3 +25,3 @@ "main": "./dist/runtime.cjs.js", | ||
"devDependencies": { | ||
"@endorphinjs/template-compiler": "^0.3.0", | ||
"@endorphinjs/template-compiler": "^0.3.1", | ||
"@types/mocha": "^5.2.6", | ||
@@ -40,3 +40,2 @@ "@types/node": "^11.13.10", | ||
}, | ||
"dependencies": {}, | ||
"repository": { | ||
@@ -53,3 +52,4 @@ "type": "git", | ||
"spec": "./test/*.ts" | ||
} | ||
}, | ||
"gitHead": "47f79120f9f1425203364bea0a8ed63cd5eef211" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
383353
4493