Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 3x 3x 3x 237x 3x 3x 3x 4x 2x 2x 2x 2x 2x 9x 2x 3x 3x 8x 8x 1x 3x 3x | import { CustomElementMetadata, CustomElementPropertyMetadata, CustomElementStateMetadata } from "../interfaces";
const htmlElementProperties: Set<string> = new Set<string>();
const element = new HTMLElement();
for (const key in element) {
//if (Object.prototype.hasOwnProperty.call(object, key)) {
htmlElementProperties.add(key)
//}
}
/**
* Tracks the custom element metadata by the class type
*/
// This is done to bypass weird behaviour with javascript regarding inherited static objects
const classMetadataRegistry = new Map<Function, CustomElementMetadata>();
/**
*
* @param Base Merges the metadata of the custom element
* @returns
*/
const MetadataMergerMixin = Base =>
class MetadataMerger extends Base {
protected static get metadata(): CustomElementMetadata {
if (!classMetadataRegistry.has(this)) {
const properties = new Map<string, CustomElementPropertyMetadata>();
const state = new Map<string, CustomElementStateMetadata>();
const observedAttributes: string[] = [];
let ctor = this as any;
while (ctor !== HTMLElement) {
if (ctor.properties !== undefined) {
Object.values(ctor.properties).forEach((p: CustomElementPropertyMetadata) => {
properties.set(p.name, p);
observedAttributes.push(p.attribute.toLowerCase());
});
}
Iif (ctor.state !== undefined) {
Object.values(ctor.state).forEach((s: CustomElementStateMetadata) => state.set(s.name, s));
}
ctor = Object.getPrototypeOf(ctor.prototype).constructor;
}
classMetadataRegistry.set(this, {
properties,
state,
observedAttributes,
htmlElementProperties
});
}
return classMetadataRegistry.get(this);
}
}
export default MetadataMergerMixin;
|