aurelia-templating-resources
Version:
A standard set of behaviors, converters and other resources for use with the Aurelia templating library.
49 lines (40 loc) • 1.2 kB
text/typescript
/*eslint padded-blocks:0*/
import {useView, customElement, bindable, useShadowDOM} from 'aurelia-templating';
import { getLogger } from 'aurelia-logging';
export function _createDynamicElement({ name, viewUrl, bindableNames, useShadowDOMmode }: {
name: string,
viewUrl: string,
bindableNames: string[],
useShadowDOMmode: null | '' | 'open' | 'closed'
}): Function {
(name)
(viewUrl)
class DynamicElement {
$parent: any;
bind(bindingContext) {
this.$parent = bindingContext;
}
}
for (let i = 0, ii = bindableNames.length; i < ii; ++i) {
bindable(bindableNames[i])(DynamicElement);
}
switch (useShadowDOMmode) {
case 'open':
useShadowDOM({ mode: 'open' })(DynamicElement);
break;
case 'closed':
useShadowDOM({ mode: 'closed' })(DynamicElement);
break;
case '':
useShadowDOM(DynamicElement);
break;
case null:
// Do not use shadow dom
break;
default:
getLogger('aurelia-html-only-element')
.warn(`Expected 'use-shadow-dom' value to be "close", "open" or "", received ${useShadowDOMmode}`);
break;
}
return DynamicElement;
}