@wildebeest/component
Advanced tools
Comparing version 0.1.3 to 0.2.0
@@ -14,3 +14,4 @@ import { ComponentBinder } from "./ComponentBinder"; | ||
}): void; | ||
bindToElement(element: HTMLElement): Map<string, Array<Component>>; | ||
autoBind(element: HTMLElement): Map<string, Array<Component>>; | ||
bindToElement(element: any, component: Component): void; | ||
} |
@@ -17,3 +17,3 @@ "use strict"; | ||
}; | ||
ComponentBindService.prototype.bindToElement = function (element) { | ||
ComponentBindService.prototype.autoBind = function (element) { | ||
var result = new Map(); | ||
@@ -31,2 +31,8 @@ for (var key in this.binders) { | ||
}; | ||
ComponentBindService.prototype.bindToElement = function (element, component) { | ||
if (!element.wbComponents) { | ||
element.wbComponents = []; | ||
} | ||
element.wbComponents.push(component); | ||
}; | ||
ComponentBindService = __decorate([ | ||
@@ -33,0 +39,0 @@ inversify_1.injectable() |
{ | ||
"name": "@wildebeest/component", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Components", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -15,3 +15,3 @@ import { injectable } from "inversify"; | ||
public bindToElement(element: HTMLElement): Map<string, Array<Component>> | ||
public autoBind(element: HTMLElement): Map<string, Array<Component>> | ||
{ | ||
@@ -30,2 +30,10 @@ let result: Map<string, Array<Component>> = new Map(); | ||
} | ||
public bindToElement(element: any, component: Component): void | ||
{ | ||
if (!element.wbComponents) { | ||
element.wbComponents = []; | ||
} | ||
element.wbComponents.push(component); | ||
} | ||
} |
@@ -53,3 +53,3 @@ import 'ts-jest'; | ||
test("binding HTML element to component", () => { | ||
test("auto binding", () => { | ||
componentBindService.addBinder('test', { | ||
@@ -62,6 +62,20 @@ selector: '.test', | ||
domService.insert([element], document.body); | ||
let components: Map<string, Array<Component>> = bindService.bindToElement(document.body); | ||
let components: Map<string, Array<Component>> = bindService.autoBind(document.body); | ||
expect(components.get('test')).toBeDefined(); | ||
expect(components.get('test').length).toEqual(1); | ||
}); | ||
test("binding HTML element to component", () => { | ||
componentBindService.addBinder('test', { | ||
selector: '.test', | ||
binder: new TestComponentBinder(emitterService) | ||
}); | ||
let element: any = domService.create('<div class="test"></div>'); | ||
let component: Component = new TestComponent(element, emitterService.createEmitter()); | ||
bindService.bindToElement(element, component); | ||
expect(element.wbComponents).toBeDefined(); | ||
expect(element.wbComponents.length).toEqual(1); | ||
}); |
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
16976
299