@boulevard/cdk
Advanced tools
Comparing version 1.0.0-alpha.5 to 1.0.0-alpha.6
{ | ||
"name": "@boulevard/cdk", | ||
"version": "1.0.0-alpha.5", | ||
"version": "1.0.0-alpha.6", | ||
"description": "Component development kit.", | ||
@@ -10,3 +10,3 @@ "main": "index.ts", | ||
"peerDependencies": { | ||
"@boulevard/lib": "^1.0.0-alpha.1", | ||
"@boulevard/lib": "^1.0.0-alpha.3", | ||
"lit-element": "^2.0.1", | ||
@@ -17,3 +17,3 @@ "reflect-metadata": "^0.1.13", | ||
"devDependencies": { | ||
"@boulevard/lib": "^1.0.0-alpha.1", | ||
"@boulevard/lib": "^1.0.0-alpha.3", | ||
"lit-element": "^2.0.1", | ||
@@ -20,0 +20,0 @@ "reflect-metadata": "^0.1.13", |
@@ -0,4 +1,6 @@ | ||
import { ClassElementDescriptor } from '@boulevard/lib/src/types'; | ||
const sealed = Symbol('@bind:sealed'); | ||
export function bind<T>(target: T, methodName: string, descriptor: PropertyDescriptor) { | ||
function lagacyBind<T>(target: T, methodName: string, descriptor: PropertyDescriptor): PropertyDescriptor { | ||
return { | ||
@@ -23,1 +25,34 @@ configurable: true, | ||
} | ||
function standardBind(elementDescriptor: ClassElementDescriptor): ClassElementDescriptor { | ||
if (elementDescriptor.kind !== 'method') { | ||
throw new Error('Attempting to bind to non-method'); | ||
} | ||
elementDescriptor.extras = [{ | ||
descriptor: { | ||
...elementDescriptor.descriptor, | ||
value: undefined | ||
}, | ||
initializer() { | ||
return this[elementDescriptor.key].bind(this); | ||
}, | ||
key: elementDescriptor.key, | ||
kind: 'field', | ||
placement: 'own' | ||
}]; | ||
return elementDescriptor; | ||
} | ||
export function bind(descriptor: ClassElementDescriptor): ClassElementDescriptor; | ||
export function bind<T>(target: T, methodName: string, descriptor: PropertyDescriptor): PropertyDescriptor; | ||
export function bind(...args: any[]) { | ||
if (args.length === 1) { | ||
// @ts-ignore | ||
return standardBind(...args); | ||
} | ||
// @ts-ignore | ||
return lagacyBind(...args); | ||
} |
@@ -1,2 +0,2 @@ | ||
import { closest as closestElement } from "@boulevard/lib/src/element"; | ||
import { closest as closestElement } from '@boulevard/lib/src/element'; | ||
@@ -3,0 +3,0 @@ export function closest(selector: string) { |
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
5722
153