Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function extractListenerInfo_(component, value) {
const info = {
fn: value
};
if (isObject(value) && !isFunction(value)) {
info.selector = value.selector;
info.fn = value.fn;
}
if (isString(info.fn)) {
info.fn = getComponentFn(component, info.fn);
}
return info;
}
toIncDom(value) {
if (isObject(value) && isString(value.content) && (value.contentKind === 'HTML')) {
value = value.content;
}
if (isString(value)) {
value = HTML2IncDom.buildFn(value);
}
return value;
}
}
const isMultiple = module => {
return isObject(module.route) && module.route.multiple;
};
export function defineWebComponent(tagName, Ctor) {
if (!('customElements' in window)) {
return;
}
let observedAttributes = Object.keys(State.getStateStatic(Ctor));
const props = getStaticProperty(Ctor, 'PROPS', mergeState);
const hasProps = isObject(props) && Object.keys(props).length;
if (hasProps) {
observedAttributes = Object.keys(props);
}
/**
* Custom Element wrapper for Metal components.
*
* @constructor
* @extends HTMLElement
*/
function CustomElement() {
return Reflect.construct(HTMLElement, [], CustomElement);
}
CustomElement.observedAttributes = observedAttributes;
shouldInformChange_(name, prevVal) {
const info = this.getStateInfo(name);
return (info.state === State.KeyStates.INITIALIZED) &&
(isObject(prevVal) || prevVal !== this.get(name));
}
export function toggleClasses(element, classes) {
if (!isObject(element) || !isString(classes)) {
return;
}
if ('classList' in element) {
toggleClassesWithNative_(element, classes);
} else {
toggleClassesWithoutNative_(element, classes);
}
}
value: function(item) {
if (core.isString(item)) {
item = {
textPrimary: item,
};
}
if (core.isObject(item) && !item.text) {
item.text = item.textPrimary;
}
return item;
},
},
validatorEventsFn_(val) {
return !isDefAndNotNull(val) || isObject(val);
}
}