generated from garrettmills/template-npm-typescript
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.5 KiB
56 lines
1.5 KiB
3 years ago
|
function setPropertyElementMapping(target: any, property: string|symbol, selector: string) {
|
||
|
if ( !target.exPropertyElementMapping ) {
|
||
|
target.exPropertyElementMapping = []
|
||
|
}
|
||
|
|
||
|
target.exPropertyElementMapping.push({
|
||
|
property,
|
||
|
selector,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
export const Element = (selector: string): PropertyDecorator => {
|
||
|
return (target, property) => {
|
||
|
setPropertyElementMapping(target.constructor, property, selector)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function setPropertyAttributeMapping(target: any, property: string|symbol, attribute: string) {
|
||
|
if ( !target.exPropertyAttributeMapping ) {
|
||
|
target.exPropertyAttributeMapping = []
|
||
|
}
|
||
|
|
||
|
target.exPropertyAttributeMapping.push({
|
||
|
property,
|
||
|
attribute,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
export const Attribute = (attribute?: string): PropertyDecorator => {
|
||
|
return (target, property) => {
|
||
|
setPropertyAttributeMapping(target.constructor, property, attribute || String(property))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function setPropertyRendersMapping(target: any, property: string|symbol) {
|
||
|
if ( !target.exPropertyRendersMapping ) {
|
||
|
target.exPropertyRendersMapping = []
|
||
|
}
|
||
|
|
||
|
target.exPropertyRendersMapping.push({
|
||
|
property,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
export const Renders = (): PropertyDecorator => {
|
||
|
return (target, property) => {
|
||
|
setPropertyRendersMapping(target.constructor, property)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export const Component = (selector: string): ClassDecorator => {
|
||
|
return (target) => {
|
||
|
window.customElements.define(selector, target as any)
|
||
|
}
|
||
|
}
|