nbhi 0.6.2 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,129 @@
1
+ export { getAttributeMapping, updateAttributes };
2
+
3
+ const mapping = {
4
+ boolean: {
5
+ autofocus: ['button', 'input', 'select', 'textarea'],
6
+ autoplay: ['audio', 'video'],
7
+ checked: ['input'],
8
+ controls: ['audio', 'video'],
9
+ default: ['track'],
10
+ defer: ['script'],
11
+ disabled: ['button', 'input', 'optgroup', 'option', 'select', 'textarea', 'fieldset'],
12
+ formnovalidate: ['button', 'input'],
13
+ ismap: ['img'],
14
+ loop: ['audio', 'video'],
15
+ multiple: ['input', 'select'],
16
+ muted: ['audio', 'video'],
17
+ novalidate: ['form'],
18
+ open: ['details', 'dialog'],
19
+ playsinline: ['video'],
20
+ readonly: ['input', 'textarea'],
21
+ required: ['input', 'select', 'textarea'],
22
+ reversed: ['ol'],
23
+ },
24
+ keyValue: {
25
+ accept: ['input'],
26
+ autocomplete: ['input', 'select', 'textarea'],
27
+ cols: ['textarea'],
28
+ dirname: ['input', 'textarea'],
29
+ max: ['input'],
30
+ maxlength: ['input', 'textarea'],
31
+ min: ['input'],
32
+ minlength: ['input', 'textarea'],
33
+ name: ['input', 'select', 'textarea'],
34
+ pattern: ['input'],
35
+ placeholder: ['input', 'textarea'],
36
+ rows: ['textarea'],
37
+ size: ['input', 'select'],
38
+ step: ['input'],
39
+ type: ['input'],
40
+ value: ['input', 'select'],
41
+ width: ['input'],
42
+ wrap: ['textarea'],
43
+ htmlFor: ['label'],
44
+ for: ['label'],
45
+ href: ['a'],
46
+ target: ['a'],
47
+ src: ['audio', 'img', 'input', 'video'],
48
+ 'aria-invalid': ['input', 'textarea', 'select'],
49
+ },
50
+ excludedAttributes: ['class', 'extends', 'id', 'part', 'data-slot', 'child'],
51
+ excludedElements: ['slot', 'template', 'style', 'script'],
52
+ };
53
+
54
+ function getAttributeMapping(element) {
55
+ const { keyValue, excludedAttributes, excludedElements, boolean: binary } = mapping;
56
+ const results = {};
57
+ traverse(element);
58
+ return results;
59
+
60
+ function traverse(element) {
61
+ const tagName = element.localName;
62
+ if (
63
+ element &&
64
+ typeof tagName === 'string' &&
65
+ !excludedElements.includes(element.localName)
66
+ ) {
67
+ Object
68
+ .entries(binary)
69
+ .filter(([key]) => !excludedAttributes.includes(key))
70
+ .filter(([, tagNames]) => tagNames.includes(tagName))
71
+ .forEach(([key, tagNames]) => results[key] = { type: 'boolean', tagNames });
72
+
73
+ Object
74
+ .entries(keyValue)
75
+ .filter(([key]) => !excludedAttributes.includes(key))
76
+ .filter(([, tagNames]) => tagNames.includes(tagName))
77
+ .forEach(([key, tagNames]) => results[key] = { type: 'keyValue', tagNames });
78
+
79
+ if (element.hasAttributes()) {
80
+ [...element.attributes].forEach(attribute => {
81
+ const name = attribute.name;
82
+ if (!excludedAttributes.includes(name)) {
83
+ if (!results[name]) {
84
+ results[name] = { type: 'userDefined', tagNames: [] };
85
+ }
86
+
87
+ if (!results[name].tagNames.includes(tagName)) {
88
+ results[name].tagNames.push(tagName);
89
+ }
90
+ }
91
+ });
92
+ }
93
+ }
94
+ [...element.children].forEach(child => traverse(child));
95
+ }
96
+ };
97
+
98
+ function updateAttributes({ name, value, attributeMapping, root }) {
99
+ const { type, tagNames = [] } = attributeMapping[name] ?? [];
100
+
101
+ if (type === 'userDefined') {
102
+ process(root.querySelector(`[${ name }]`));
103
+ } else {
104
+ tagNames.forEach(tagName => {
105
+ root.querySelectorAll(tagName).forEach(process);
106
+ if (tagName === root?.localName) {
107
+ process(root);
108
+ }
109
+ });
110
+ }
111
+
112
+ function process(element) {
113
+ if (element) {
114
+ if (
115
+ value === null ||
116
+ value === undefined ||
117
+ (type === 'boolean' && value === false)
118
+ ) {
119
+ element.removeAttribute(name);
120
+ } else {
121
+ element.setAttribute(name, value);
122
+ // Triggers <select> to update the selected <option>
123
+ if (name === 'value') {
124
+ element.value = value;
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
@@ -0,0 +1,11 @@
1
+ export default selector => {
2
+ if (typeof selector === 'string') {
3
+ const instance = document.querySelector(selector);
4
+ if (!instance) {
5
+ throw new Error(`No elements found for selector ${ selector }`);
6
+ }
7
+ return instance;
8
+ }
9
+
10
+ return selector;
11
+ };
@@ -0,0 +1,149 @@
1
+ import { getAttributeMapping, updateAttributes } from './attributes.js';
2
+ import update from './update.js';
3
+ import validate from './validate.js';
4
+ import onceVisible from './onceVisible.js';
5
+
6
+ export { initialize, update, validate, onceVisible };
7
+
8
+ async function initialize({ prefix = 'db', source = '/components' } = {}) {
9
+ const registerCache = new Set();
10
+ const fileCache = new Set();
11
+
12
+ if (typeof source !== 'string' || !Object.keys(source).length) {
13
+ throw new Error('source option needs to be a string or an object');
14
+ }
15
+
16
+ if (typeof prefix !== 'string' || prefix === '') {
17
+ throw new Error('prefix option needs to be a string of at least one character');
18
+ }
19
+
20
+ const inheritedStylesheets = getInheritedStylesheets();
21
+ inPage(document.querySelector('body'));
22
+ await fromFile(document.querySelector('body'));
23
+
24
+ function inPage(root, parentId) {
25
+ root.querySelectorAll('template').forEach(template => {
26
+ if (!template.id && parentId) {
27
+ template.id = `${ parentId }-child`;
28
+ }
29
+
30
+ if (!template.id) {
31
+ console.log(template, parentId);
32
+ throw new Error('<template> is missing a mandatory id field');
33
+ }
34
+
35
+ inPage(template.content, template.id);
36
+ const name = template.id;
37
+ register({ name, template });
38
+ });
39
+ }
40
+
41
+ function fromFile(root) {
42
+ const promises = [...root.querySelectorAll(':not(:defined)')]
43
+ .filter(element => {
44
+ const tagName = element.localName;
45
+ return element.nodeType === 1 && tagName.includes('-') && tagName.startsWith(prefix);
46
+ })
47
+ .map(async element => {
48
+ const name = element.localName;
49
+ if (!fileCache.has(name)) {
50
+ fileCache.add(name);
51
+ const html = await fetchFromFile(name);
52
+ const template = document.createElement('template');
53
+ template.content.append(...html.children);
54
+ const script = await copyScript(template);
55
+ await fromFile(template.content);
56
+ inPage(template.content, name);
57
+ register({ name, template, script });
58
+
59
+ function copyScript(template) {
60
+ const script = template.content.querySelector('script');
61
+ return new Promise(async resolve => {
62
+ if (script) {
63
+ const blob = new Blob([script.textContent], { type: 'text/javascript' });
64
+ const blobUrl = URL.createObjectURL(blob);
65
+ resolve((await import(blobUrl)).default);
66
+ URL.revokeObjectURL(blobUrl);
67
+ } else {
68
+ resolve({});
69
+ }
70
+ });
71
+ }
72
+ };
73
+
74
+ async function fetchFromFile(name) {
75
+ const fileName = name.split('-').slice(1).join('-');
76
+ const relativePath = typeof source === 'string'
77
+ ? `${ source }/${ fileName }.html` : source[fileName];
78
+ const response = await fetch(relativePath);
79
+ if (!response.ok) {
80
+ throw new Error(`Could not find component @ ${ relativePath }`);
81
+ }
82
+ const templateAsString = await response.text();
83
+ const document = new DOMParser().parseFromString(templateAsString, 'text/html');
84
+ return document.querySelector('body');
85
+ }
86
+ });
87
+
88
+ return Promise.all(promises);
89
+ }
90
+
91
+ function register({ name, template, script }) {
92
+ if (registerCache.has(name)) {
93
+ return;
94
+ }
95
+
96
+ registerCache.add(name);
97
+
98
+ const isFormControl = !!template.content.querySelector('input, select, textarea');
99
+ const attributeMapping = getAttributeMapping(template.content);
100
+
101
+ customElements.define(name, class extends HTMLElement {
102
+ static observedAttributes = Object.keys(attributeMapping);
103
+ static formAssociated = isFormControl;
104
+ #shadow = null;
105
+
106
+ constructor() {
107
+ super();
108
+
109
+ const clone = document.importNode(template.content, true);
110
+ this.#shadow = this.attachShadow({ mode: 'open' });
111
+ this.#shadow.adoptedStyleSheets = inheritedStylesheets;
112
+ this.#shadow.appendChild(clone);
113
+
114
+ if (isFormControl) {
115
+ this.elementInternals = this.attachInternals();
116
+ this.formElement = this.#shadow.querySelector('input, select, textarea');
117
+ }
118
+ }
119
+
120
+ connectedCallback() {
121
+ if (typeof script === 'function') {
122
+ script(this);
123
+ }
124
+ }
125
+
126
+ attributeChangedCallback(name, oldValue, newValue) {
127
+ if (oldValue !== newValue) {
128
+ updateAttributes({ name, value: newValue, attributeMapping, root: this.#shadow });
129
+ }
130
+ }
131
+ });
132
+ };
133
+
134
+ function getInheritedStylesheets() {
135
+ return Array.from(document.styleSheets)
136
+ .filter(sheet => sheet?.ownerNode?.dataset?.inherit === 'true')
137
+ .map(sheet => {
138
+ const newSheet = new CSSStyleSheet();
139
+ try {
140
+ const cssText = Array.from(sheet.cssRules).map(rule => rule.cssText).join('\n');
141
+ newSheet.replaceSync(cssText);
142
+ } catch (error) {
143
+ error;
144
+ console.error('Permission denied for sheet:', sheet.href);
145
+ }
146
+ return newSheet;
147
+ });
148
+ }
149
+ };
@@ -0,0 +1,11 @@
1
+ import element from './element.js';
2
+
3
+ export default (selector, callback) => {
4
+ const observer = new IntersectionObserver(entries => {
5
+ if (entries[0].isIntersecting) {
6
+ callback();
7
+ observer.disconnect();
8
+ }
9
+ });
10
+ observer.observe(element(selector));
11
+ };
@@ -0,0 +1,215 @@
1
+ import { getAttributeMapping, updateAttributes } from './attributes.js';
2
+ import element from './element.js';
3
+
4
+ export default selector => {
5
+ const instance = element(selector);
6
+ const idCache = new WeakMap();
7
+ const mappingCache = new WeakMap();
8
+ let renderedChildren = new Map();
9
+ let idCount = 1;
10
+ let templateChild;
11
+
12
+ return data => {
13
+ if (isDate(data)) {
14
+ throw new Error('Please convert date to string, ie. toISOString()');
15
+ }
16
+
17
+ if (isArray(data)) {
18
+ updateList(data);
19
+ } else {
20
+ if (isPrimitive(data)) {
21
+ updateText(instance, data);
22
+ } else if (isObject(data)) {
23
+ updateFromObject(instance, data);
24
+ }
25
+ }
26
+
27
+ function isDate(input) {
28
+ return input?.getTime !== undefined;
29
+ }
30
+
31
+ function isPrimitive(input) {
32
+ return !isArray(input) && !isObject(input);
33
+ }
34
+
35
+ function isObject(input) {
36
+ return !isArray(input) && input !== null && typeof input === 'object' && Object.keys(input).length;
37
+ }
38
+
39
+ function isArray(input) {
40
+ return Array.isArray(input);
41
+ }
42
+
43
+ function updateFromObject(element, data) {
44
+ Object.entries(data).forEach(([key, value]) => {
45
+ if (key.startsWith('$')) {
46
+ const name = key.slice(1);
47
+ if (element.shadowRoot) {
48
+ if (value === false) {
49
+ element.removeAttribute(name);
50
+ } else if (value === true) {
51
+ element.setAttribute(name, '');
52
+ } else {
53
+ element.setAttribute(name, value);
54
+ }
55
+ } else {
56
+ if (!mappingCache.has(element)) {
57
+ mappingCache.set(element, getAttributeMapping(element));
58
+ }
59
+ const attributeMapping = mappingCache.get(element);
60
+ updateAttributes({ name, value, attributeMapping, root: element });
61
+ }
62
+ } else {
63
+ updateText(element, value, key);
64
+ }
65
+ });
66
+ }
67
+
68
+ function updateText(element, value, name) {
69
+ if (element.localName === 'option') {
70
+ element.textContent = value;
71
+ } else if (
72
+ element.localName === 'tr' ||
73
+ element.localName === 'li' ||
74
+ (element.hasAttribute('child') && !element.shadowRoot)) {
75
+ if (element.hasAttribute('data-slot') && element.dataset.slot === name) {
76
+ element.textContent = value;
77
+ } else {
78
+ const match = element.querySelector(`[data-slot="${ name }"]`);
79
+ if (match) {
80
+ match.textContent = value;
81
+ }
82
+ }
83
+ } else if (!name && element.textContent !== value) {
84
+ element.textContent = value;
85
+ } else {
86
+ let slot = element.querySelector(`[slot="${ name }"]`);
87
+ if (!slot) {
88
+ slot = document.createElement('span');
89
+ slot.setAttribute('slot', name);
90
+ element.append(slot);
91
+ }
92
+
93
+ if (slot.textContent !== value) {
94
+ slot.textContent = value;
95
+ }
96
+ }
97
+ }
98
+
99
+ function updateList(records) {
100
+ const parent = getParent();
101
+
102
+ if (!templateChild) {
103
+ throw new Error(`Cannot update ${ selector }, cannot find child element`);
104
+ }
105
+
106
+ const newChildren = new Map();
107
+
108
+ records.forEach((record, index) => {
109
+ const id = getId(record, index);
110
+ let child = renderedChildren.get(id);
111
+
112
+ if (!child) {
113
+ child = templateChild.cloneNode(true);
114
+ parent.append(child);
115
+ }
116
+
117
+ if (child.cachedData !== record) {
118
+ if (isObject(record)) {
119
+ updateFromObject(child, record);
120
+ } else {
121
+ updateText(child, record);
122
+ }
123
+ child.cachedData = record;
124
+ }
125
+
126
+ newChildren.set(id, child);
127
+ });
128
+
129
+ renderedChildren.forEach((child, id) => {
130
+ if (!newChildren.has(id)) {
131
+ child.remove();
132
+ }
133
+ });
134
+
135
+ // Order children
136
+ let lastChild;
137
+ newChildren.forEach(child => {
138
+ if (child !== lastChild?.nextSibling) {
139
+ parent.insertBefore(child, lastChild ? lastChild.nextSibling : parent.firstChild);
140
+ }
141
+ lastChild = child;
142
+ });
143
+
144
+ renderedChildren = newChildren;
145
+
146
+ function getId(record, index) {
147
+ if (record && typeof record === 'object') {
148
+ if (!idCache.has(record)) {
149
+ idCache.set(record, idCount++);
150
+ }
151
+ return idCache.get(record);
152
+ }
153
+ return `p:${ record }:${ index }`;
154
+ };
155
+
156
+ function getParent() {
157
+ const topLevel = getTopLevel();
158
+ if (topLevel.localName === 'table') {
159
+ return process('tbody', 'tr');
160
+ } else if (topLevel.localName === 'ol') {
161
+ return process('ol', 'li');
162
+ } else if (topLevel.localName === 'ul') {
163
+ return process('ul', 'li');
164
+ } else if (topLevel.localName === 'select') {
165
+ return process('select', 'option');
166
+ } else if (topLevel.querySelector('[child]')) {
167
+ const parent = getParent(topLevel.querySelector('[child]')).parentElement;
168
+ setTemplateChild('[child]', parent);
169
+ if (parent.localName === 'slot' && parent.hasAttribute('name')) {
170
+ templateChild.slot = parent.getAttribute('name');
171
+ }
172
+ return parent.localName === 'slot' ? instance : parent;
173
+ }
174
+
175
+ throw new Error(`Could not find a parent to assign children to, valid
176
+ options are table, ul, ol, select or a structure with a child attribute`);
177
+
178
+ function process(parentName, childName) {
179
+ const parent = getParent(parentName);
180
+ setTemplateChild(childName, parent);
181
+ return parent;
182
+ }
183
+
184
+ function setTemplateChild(childName, parent) {
185
+ if (!templateChild) {
186
+ templateChild = parent.querySelector(childName).cloneNode(true);
187
+ parent.replaceChildren();
188
+ }
189
+ }
190
+
191
+ function getParent(parentName) {
192
+ if (parentName === topLevel.localName) {
193
+ return topLevel;
194
+ }
195
+ const parent = typeof parentName === 'string'
196
+ ? topLevel.querySelector(parentName) : parentName;
197
+ if (!parent) {
198
+ console.log({ topLevel, parentName });
199
+ throw new Error('Cannot find parent');
200
+ }
201
+ return parent;
202
+ }
203
+
204
+ function getTopLevel() {
205
+ if (instance.tagName.includes('-')) {
206
+ return [...instance.shadowRoot.children].find(child => {
207
+ return child.localName !== 'script' && child.localName !== 'style';
208
+ });
209
+ }
210
+ return instance;
211
+ }
212
+ }
213
+ }
214
+ };
215
+ };
@@ -0,0 +1,39 @@
1
+ import element from './element.js';
2
+
3
+ // Too long and too short is only set when the actual input is changed, so we do it here
4
+ export default selector => {
5
+ const instance = element(selector);
6
+ if (instance.elementInternals) {
7
+ const element = instance.formElement;
8
+ const value = element.value;
9
+ const minlength = element.getAttribute('minlength');
10
+ const maxlength = element.getAttribute('maxlength');
11
+ const validity = {
12
+ valueMissing: element.validity.valueMissing,
13
+ typeMismatch: element.validity.typeMismatch,
14
+ patternMismatch: element.validity.patternMismatch,
15
+ rangeUnderflow: element.validity.rangeUnderflow,
16
+ rangeOverflow: element.validity.rangeOverflow,
17
+ stepMismatch: element.validity.stepMismatch,
18
+ badInput: element.validity.badInput,
19
+ customError: element.validity.customError,
20
+ tooShort: minlength ? value.length < parseInt(minlength) : false,
21
+ tooLong: maxlength ? value.length > parseInt(maxlength) : false,
22
+ };
23
+ instance.elementInternals.setFormValue(value);
24
+ instance.elementInternals.setValidity(validity, message(), element);
25
+
26
+ return instance.elementInternals;
27
+
28
+ function message() {
29
+ if (validity.tooShort) {
30
+ return `The text needs to be at least ${ minlength } characters long`;
31
+ } else if (validity.tooLong) {
32
+ return `The text needs to be at most ${ maxlength } characters long`;
33
+ } else if (element.validationMessage) {
34
+ return element.validationMessage;
35
+ }
36
+ return 'The value is invalid';
37
+ }
38
+ }
39
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nbhi",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "No-Build HTML Includes (NBHI) is a simple library that allows you to include html files into other html files and turns them into [web components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components). Lazy initialization of content (when entering the viewport) and a one line call to update/hydrate content in your html pages. No build tools required, no `package.json` needed.",
5
5
  "keywords": [
6
6
  "web-components",
@@ -22,17 +22,15 @@
22
22
  "url": "git+https://github.com/royniels/nbhi.git"
23
23
  },
24
24
  "files": [
25
- "./index.min.js",
26
- "./index.min.js.map"
25
+ "./javascript/**.js"
27
26
  ],
28
27
  "exports": {
29
- ".": "./index.min.js"
28
+ ".": "./javascript/index.js"
30
29
  },
31
30
  "license": "MIT",
32
31
  "author": "Roy Niels",
33
32
  "type": "module",
34
33
  "scripts": {
35
- "test": "echo \"Error: no test specified\" && exit 1",
36
- "build": "npx esbuild ./javascript/index.js --minify --bundle --format=esm --sourcemap --outfile=index.min.js"
34
+ "test": "echo \"Error: no test specified\" && exit 1"
37
35
  }
38
36
  }
package/index.min.js DELETED
@@ -1,4 +0,0 @@
1
- var I={boolean:{autofocus:["button","input","select","textarea"],autoplay:["audio","video"],checked:["input"],controls:["audio","video"],default:["track"],defer:["script"],disabled:["button","input","optgroup","option","select","textarea","fieldset"],formnovalidate:["button","input"],ismap:["img"],loop:["audio","video"],multiple:["input","select"],muted:["audio","video"],novalidate:["form"],open:["details","dialog"],playsinline:["video"],readonly:["input","textarea"],required:["input","select","textarea"],reversed:["ol"]},keyValue:{accept:["input"],autocomplete:["input","select","textarea"],cols:["textarea"],dirname:["input","textarea"],max:["input"],maxlength:["input","textarea"],min:["input"],minlength:["input","textarea"],name:["input","select","textarea"],pattern:["input"],placeholder:["input","textarea"],rows:["textarea"],size:["input","select"],step:["input"],type:["input"],value:["input","select"],width:["input"],wrap:["textarea"],htmlFor:["label"],for:["label"],href:["a"],target:["a"],src:["audio","img","input","video"],"aria-invalid":["input","textarea","select"]},excludedAttributes:["class","extends","id","part","data-slot","child"],excludedElements:["slot","template","style","script"]};function q(c){let{keyValue:n,excludedAttributes:i,excludedElements:f,boolean:b}=I,d={};return p(c),d;function p(r){let S=r.localName;r&&typeof S=="string"&&!f.includes(r.localName)&&(Object.entries(b).filter(([o])=>!i.includes(o)).filter(([,o])=>o.includes(S)).forEach(([o,a])=>d[o]={type:"boolean",tagNames:a}),Object.entries(n).filter(([o])=>!i.includes(o)).filter(([,o])=>o.includes(S)).forEach(([o,a])=>d[o]={type:"keyValue",tagNames:a}),r.hasAttributes()&&[...r.attributes].forEach(o=>{let a=o.name;i.includes(a)||(d[a]||(d[a]={type:"userDefined",tagNames:[]}),d[a].tagNames.includes(S)||d[a].tagNames.push(S))})),[...r.children].forEach(o=>p(o))}}function j({name:c,value:n,attributeMapping:i,root:f}){let{type:b,tagNames:d=[]}=i[c]??[];b==="userDefined"?p(f.querySelector(`[${c}]`)):d.forEach(r=>{f.querySelectorAll(r).forEach(p),r===f?.localName&&p(f)});function p(r){r&&(n==null||b==="boolean"&&n===!1?r.removeAttribute(c):(r.setAttribute(c,n),c==="value"&&(r.value=n)))}}var N=c=>{if(typeof c=="string"){let n=document.querySelector(c);if(!n)throw new Error(`No elements found for selector ${c}`);return n}return c};var k=c=>{let n=N(c),i=new WeakMap,f=new WeakMap,b=new Map,d=1,p;return r=>{if(S(r))throw new Error("Please convert date to string, ie. toISOString()");s(r)?v(r):o(r)?A(n,r):a(r)&&g(n,r);function S(t){return t?.getTime!==void 0}function o(t){return!s(t)&&!a(t)}function a(t){return!s(t)&&t!==null&&typeof t=="object"&&Object.keys(t).length}function s(t){return Array.isArray(t)}function g(t,u){Object.entries(u).forEach(([h,l])=>{if(h.startsWith("$")){let x=h.slice(1);if(t.shadowRoot)l===!1?t.removeAttribute(x):l===!0?t.setAttribute(x,""):t.setAttribute(x,l);else{f.has(t)||f.set(t,q(t));let C=f.get(t);j({name:x,value:l,attributeMapping:C,root:t})}}else A(t,l,h)})}function A(t,u,h){if(t.localName==="option")t.textContent=u;else if(t.localName==="tr"||t.localName==="li"||t.hasAttribute("child")&&!t.shadowRoot)if(t.hasAttribute("data-slot")&&t.dataset.slot===h)t.textContent=u;else{let l=t.querySelector(`[data-slot="${h}"]`);l&&(l.textContent=u)}else if(!h&&t.textContent!==u)t.textContent=u;else{let l=t.querySelector(`[slot="${h}"]`);l||(l=document.createElement("span"),l.setAttribute("slot",h),t.append(l)),l.textContent!==u&&(l.textContent=u)}}function v(t){let u=C();if(!p)throw new Error(`Cannot update ${c}, cannot find child element`);let h=new Map;t.forEach((e,y)=>{let M=x(e,y),w=b.get(M);w||(w=p.cloneNode(!0),u.append(w)),w.cachedData!==e&&(a(e)?g(w,e):A(w,e),w.cachedData=e),h.set(M,w)}),b.forEach((e,y)=>{h.has(y)||e.remove()});let l;h.forEach(e=>{e!==l?.nextSibling&&u.insertBefore(e,l?l.nextSibling:u.firstChild),l=e}),b=h;function x(e,y){return e&&typeof e=="object"?(i.has(e)||i.set(e,d++),i.get(e)):`p:${e}:${y}`}function C(){let e=$();if(e.localName==="table")return y("tbody","tr");if(e.localName==="ol")return y("ol","li");if(e.localName==="ul")return y("ul","li");if(e.localName==="select")return y("select","option");if(e.querySelector("[child]")){let m=w(e.querySelector("[child]")).parentElement;return M("[child]",m),m.localName==="slot"&&m.hasAttribute("name")&&(p.slot=m.getAttribute("name")),m.localName==="slot"?n:m}throw new Error(`Could not find a parent to assign children to, valid
2
- options are table, ul, ol, select or a structure with a child attribute`);function y(m,E){let O=w(m);return M(E,O),O}function M(m,E){p||(p=E.querySelector(m).cloneNode(!0),E.replaceChildren())}function w(m){if(m===e.localName)return e;let E=typeof m=="string"?e.querySelector(m):m;if(!E)throw console.log({topLevel:e,parentName:m}),new Error("Cannot find parent");return E}function $(){return n.tagName.includes("-")?[...n.shadowRoot.children].find(m=>m.localName!=="script"&&m.localName!=="style"):n}}}}};var T=c=>{let n=N(c);if(n.elementInternals){let r=function(){return p.tooShort?`The text needs to be at least ${b} characters long`:p.tooLong?`The text needs to be at most ${d} characters long`:i.validationMessage?i.validationMessage:"The value is invalid"},i=n.formElement,f=i.value,b=i.getAttribute("minlength"),d=i.getAttribute("maxlength"),p={valueMissing:i.validity.valueMissing,typeMismatch:i.validity.typeMismatch,patternMismatch:i.validity.patternMismatch,rangeUnderflow:i.validity.rangeUnderflow,rangeOverflow:i.validity.rangeOverflow,stepMismatch:i.validity.stepMismatch,badInput:i.validity.badInput,customError:i.validity.customError,tooShort:b?f.length<parseInt(b):!1,tooLong:d?f.length>parseInt(d):!1};return n.elementInternals.setFormValue(f),n.elementInternals.setValidity(p,r(),i),n.elementInternals}};var L=(c,n)=>{let i=new IntersectionObserver(f=>{f[0].isIntersecting&&(n(),i.disconnect())});i.observe(N(c))};async function Q({prefix:c="db",source:n="/components"}={}){let i=new Set,f=new Set;if(typeof n!="string"||!Object.keys(n).length)throw new Error("source option needs to be a string or an object");if(typeof c!="string"||c==="")throw new Error("prefix option needs to be a string of at least one character");let b=S();d(document.querySelector("body")),await p(document.querySelector("body"));function d(o,a){o.querySelectorAll("template").forEach(s=>{if(!s.id&&a&&(s.id=`${a}-child`),!s.id)throw console.log(s,a),new Error("<template> is missing a mandatory id field");d(s.content,s.id);let g=s.id;r({name:g,template:s})})}function p(o){let a=[...o.querySelectorAll(":not(:defined)")].filter(s=>{let g=s.localName;return s.nodeType===1&&g.includes("-")&&g.startsWith(c)}).map(async s=>{let g=s.localName;if(!f.has(g)){let h=function(l){let x=l.content.querySelector("script");return new Promise(async C=>{if(x){let e=new Blob([x.textContent],{type:"text/javascript"}),y=URL.createObjectURL(e);C((await import(y)).default),URL.revokeObjectURL(y)}else C({})})};f.add(g);let v=await A(g),t=document.createElement("template");t.content.append(...v.children);let u=await h(t);await p(t.content),d(t.content,g),r({name:g,template:t,script:u})}async function A(v){let t=v.split("-").slice(1).join("-"),u=typeof n=="string"?`${n}/${t}.html`:n[t],h=await fetch(u);if(!h.ok)throw new Error(`Could not find component @ ${u}`);let l=await h.text();return new DOMParser().parseFromString(l,"text/html").querySelector("body")}});return Promise.all(a)}function r({name:o,template:a,script:s}){if(i.has(o))return;i.add(o);let g=!!a.content.querySelector("input, select, textarea"),A=q(a.content);customElements.define(o,class extends HTMLElement{static observedAttributes=Object.keys(A);static formAssociated=g;#t=null;constructor(){super();let v=document.importNode(a.content,!0);this.#t=this.attachShadow({mode:"open"}),this.#t.adoptedStyleSheets=b,this.#t.appendChild(v),g&&(this.elementInternals=this.attachInternals(),this.formElement=this.#t.querySelector("input, select, textarea"))}connectedCallback(){typeof s=="function"&&s(this)}attributeChangedCallback(v,t,u){t!==u&&j({name:v,value:u,attributeMapping:A,root:this.#t})}})}function S(){return Array.from(document.styleSheets).filter(o=>o?.ownerNode?.dataset?.inherit==="true").map(o=>{let a=new CSSStyleSheet;try{let s=Array.from(o.cssRules).map(g=>g.cssText).join(`
3
- `);a.replaceSync(s)}catch(s){console.error("Permission denied for sheet:",o.href)}return a})}}export{Q as initialize,L as onceVisible,k as update,T as validate};
4
- //# sourceMappingURL=index.min.js.map
package/index.min.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["javascript/attributes.js", "javascript/element.js", "javascript/update.js", "javascript/validate.js", "javascript/onceVisible.js", "javascript/index.js"],
4
- "sourcesContent": ["export { getAttributeMapping, updateAttributes };\n\nconst mapping = {\n boolean: {\n autofocus: ['button', 'input', 'select', 'textarea'],\n autoplay: ['audio', 'video'],\n checked: ['input'],\n controls: ['audio', 'video'],\n default: ['track'],\n defer: ['script'],\n disabled: ['button', 'input', 'optgroup', 'option', 'select', 'textarea', 'fieldset'],\n formnovalidate: ['button', 'input'],\n ismap: ['img'],\n loop: ['audio', 'video'],\n multiple: ['input', 'select'],\n muted: ['audio', 'video'],\n novalidate: ['form'],\n open: ['details', 'dialog'],\n playsinline: ['video'],\n readonly: ['input', 'textarea'],\n required: ['input', 'select', 'textarea'],\n reversed: ['ol'],\n },\n keyValue: {\n accept: ['input'],\n autocomplete: ['input', 'select', 'textarea'],\n cols: ['textarea'],\n dirname: ['input', 'textarea'],\n max: ['input'],\n maxlength: ['input', 'textarea'],\n min: ['input'],\n minlength: ['input', 'textarea'],\n name: ['input', 'select', 'textarea'],\n pattern: ['input'],\n placeholder: ['input', 'textarea'],\n rows: ['textarea'],\n size: ['input', 'select'],\n step: ['input'],\n type: ['input'],\n value: ['input', 'select'],\n width: ['input'],\n wrap: ['textarea'],\n htmlFor: ['label'],\n for: ['label'],\n href: ['a'],\n target: ['a'],\n src: ['audio', 'img', 'input', 'video'],\n 'aria-invalid': ['input', 'textarea', 'select'],\n },\n excludedAttributes: ['class', 'extends', 'id', 'part', 'data-slot', 'child'],\n excludedElements: ['slot', 'template', 'style', 'script'],\n};\n\nfunction getAttributeMapping(element) {\n const { keyValue, excludedAttributes, excludedElements, boolean: binary } = mapping;\n const results = {};\n traverse(element);\n return results;\n\n function traverse(element) {\n const tagName = element.localName;\n if (\n element &&\n typeof tagName === 'string' &&\n !excludedElements.includes(element.localName)\n ) {\n Object\n .entries(binary)\n .filter(([key]) => !excludedAttributes.includes(key))\n .filter(([, tagNames]) => tagNames.includes(tagName))\n .forEach(([key, tagNames]) => results[key] = { type: 'boolean', tagNames });\n\n Object\n .entries(keyValue)\n .filter(([key]) => !excludedAttributes.includes(key))\n .filter(([, tagNames]) => tagNames.includes(tagName))\n .forEach(([key, tagNames]) => results[key] = { type: 'keyValue', tagNames });\n\n if (element.hasAttributes()) {\n [...element.attributes].forEach(attribute => {\n const name = attribute.name;\n if (!excludedAttributes.includes(name)) {\n if (!results[name]) {\n results[name] = { type: 'userDefined', tagNames: [] };\n }\n\n if (!results[name].tagNames.includes(tagName)) {\n results[name].tagNames.push(tagName);\n }\n }\n });\n }\n }\n [...element.children].forEach(child => traverse(child));\n }\n};\n\nfunction updateAttributes({ name, value, attributeMapping, root }) {\n const { type, tagNames = [] } = attributeMapping[name] ?? [];\n\n if (type === 'userDefined') {\n process(root.querySelector(`[${ name }]`));\n } else {\n tagNames.forEach(tagName => {\n root.querySelectorAll(tagName).forEach(process);\n if (tagName === root?.localName) {\n process(root);\n }\n });\n }\n\n function process(element) {\n if (element) {\n if (\n value === null ||\n value === undefined ||\n (type === 'boolean' && value === false)\n ) {\n element.removeAttribute(name);\n } else {\n element.setAttribute(name, value);\n // Triggers <select> to update the selected <option>\n if (name === 'value') {\n element.value = value;\n }\n }\n }\n }\n}", "export default selector => {\n if (typeof selector === 'string') {\n const instance = document.querySelector(selector);\n if (!instance) {\n throw new Error(`No elements found for selector ${ selector }`);\n }\n return instance;\n }\n\n return selector;\n};", "import { getAttributeMapping, updateAttributes } from './attributes.js';\nimport element from './element.js';\n\nexport default selector => {\n const instance = element(selector);\n const idCache = new WeakMap();\n const mappingCache = new WeakMap();\n let renderedChildren = new Map();\n let idCount = 1;\n let templateChild;\n\n return data => {\n if (isDate(data)) {\n throw new Error('Please convert date to string, ie. toISOString()');\n }\n\n if (isArray(data)) {\n updateList(data);\n } else {\n if (isPrimitive(data)) {\n updateText(instance, data);\n } else if (isObject(data)) {\n updateFromObject(instance, data);\n }\n }\n\n function isDate(input) {\n return input?.getTime !== undefined;\n }\n\n function isPrimitive(input) {\n return !isArray(input) && !isObject(input);\n }\n\n function isObject(input) {\n return !isArray(input) && input !== null && typeof input === 'object' && Object.keys(input).length;\n }\n\n function isArray(input) {\n return Array.isArray(input);\n }\n\n function updateFromObject(element, data) {\n Object.entries(data).forEach(([key, value]) => {\n if (key.startsWith('$')) {\n const name = key.slice(1);\n if (element.shadowRoot) {\n if (value === false) {\n element.removeAttribute(name);\n } else if (value === true) {\n element.setAttribute(name, '');\n } else {\n element.setAttribute(name, value);\n }\n } else {\n if (!mappingCache.has(element)) {\n mappingCache.set(element, getAttributeMapping(element));\n }\n const attributeMapping = mappingCache.get(element);\n updateAttributes({ name, value, attributeMapping, root: element });\n }\n } else {\n updateText(element, value, key);\n }\n });\n }\n\n function updateText(element, value, name) {\n if (element.localName === 'option') {\n element.textContent = value;\n } else if (\n element.localName === 'tr' ||\n element.localName === 'li' ||\n (element.hasAttribute('child') && !element.shadowRoot)) {\n if (element.hasAttribute('data-slot') && element.dataset.slot === name) {\n element.textContent = value;\n } else {\n const match = element.querySelector(`[data-slot=\"${ name }\"]`);\n if (match) {\n match.textContent = value;\n }\n }\n } else if (!name && element.textContent !== value) {\n element.textContent = value;\n } else {\n let slot = element.querySelector(`[slot=\"${ name }\"]`);\n if (!slot) {\n slot = document.createElement('span');\n slot.setAttribute('slot', name);\n element.append(slot);\n }\n\n if (slot.textContent !== value) {\n slot.textContent = value;\n }\n }\n }\n\n function updateList(records) {\n const parent = getParent();\n\n if (!templateChild) {\n throw new Error(`Cannot update ${ selector }, cannot find child element`);\n }\n\n const newChildren = new Map();\n\n records.forEach((record, index) => {\n const id = getId(record, index);\n let child = renderedChildren.get(id);\n\n if (!child) {\n child = templateChild.cloneNode(true);\n parent.append(child);\n }\n\n if (child.cachedData !== record) {\n if (isObject(record)) {\n updateFromObject(child, record);\n } else {\n updateText(child, record);\n }\n child.cachedData = record;\n }\n\n newChildren.set(id, child);\n });\n\n renderedChildren.forEach((child, id) => {\n if (!newChildren.has(id)) {\n child.remove();\n }\n });\n\n // Order children\n let lastChild;\n newChildren.forEach(child => {\n if (child !== lastChild?.nextSibling) {\n parent.insertBefore(child, lastChild ? lastChild.nextSibling : parent.firstChild);\n }\n lastChild = child;\n });\n\n renderedChildren = newChildren;\n\n function getId(record, index) {\n if (record && typeof record === 'object') {\n if (!idCache.has(record)) {\n idCache.set(record, idCount++);\n }\n return idCache.get(record);\n }\n return `p:${ record }:${ index }`;\n };\n\n function getParent() {\n const topLevel = getTopLevel();\n if (topLevel.localName === 'table') {\n return process('tbody', 'tr');\n } else if (topLevel.localName === 'ol') {\n return process('ol', 'li');\n } else if (topLevel.localName === 'ul') {\n return process('ul', 'li');\n } else if (topLevel.localName === 'select') {\n return process('select', 'option');\n } else if (topLevel.querySelector('[child]')) {\n const parent = getParent(topLevel.querySelector('[child]')).parentElement;\n setTemplateChild('[child]', parent);\n if (parent.localName === 'slot' && parent.hasAttribute('name')) {\n templateChild.slot = parent.getAttribute('name');\n }\n return parent.localName === 'slot' ? instance : parent;\n }\n\n throw new Error(`Could not find a parent to assign children to, valid\n options are table, ul, ol, select or a structure with a child attribute`);\n\n function process(parentName, childName) {\n const parent = getParent(parentName);\n setTemplateChild(childName, parent);\n return parent;\n }\n\n function setTemplateChild(childName, parent) {\n if (!templateChild) {\n templateChild = parent.querySelector(childName).cloneNode(true);\n parent.replaceChildren();\n }\n }\n\n function getParent(parentName) {\n if (parentName === topLevel.localName) {\n return topLevel;\n }\n const parent = typeof parentName === 'string'\n ? topLevel.querySelector(parentName) : parentName;\n if (!parent) {\n console.log({ topLevel, parentName });\n throw new Error('Cannot find parent');\n }\n return parent;\n }\n\n function getTopLevel() {\n if (instance.tagName.includes('-')) {\n return [...instance.shadowRoot.children].find(child => {\n return child.localName !== 'script' && child.localName !== 'style';\n });\n }\n return instance;\n }\n }\n }\n };\n};", "import element from './element.js';\n\n// Too long and too short is only set when the actual input is changed, so we do it here\nexport default selector => {\n const instance = element(selector);\n if (instance.elementInternals) {\n const element = instance.formElement;\n const value = element.value;\n const minlength = element.getAttribute('minlength');\n const maxlength = element.getAttribute('maxlength');\n const validity = {\n valueMissing: element.validity.valueMissing,\n typeMismatch: element.validity.typeMismatch,\n patternMismatch: element.validity.patternMismatch,\n rangeUnderflow: element.validity.rangeUnderflow,\n rangeOverflow: element.validity.rangeOverflow,\n stepMismatch: element.validity.stepMismatch,\n badInput: element.validity.badInput,\n customError: element.validity.customError,\n tooShort: minlength ? value.length < parseInt(minlength) : false,\n tooLong: maxlength ? value.length > parseInt(maxlength) : false,\n };\n instance.elementInternals.setFormValue(value);\n instance.elementInternals.setValidity(validity, message(), element);\n\n return instance.elementInternals;\n\n function message() {\n if (validity.tooShort) {\n return `The text needs to be at least ${ minlength } characters long`;\n } else if (validity.tooLong) {\n return `The text needs to be at most ${ maxlength } characters long`;\n } else if (element.validationMessage) {\n return element.validationMessage;\n }\n return 'The value is invalid';\n }\n }\n};", "import element from './element.js';\n\nexport default (selector, callback) => {\n const observer = new IntersectionObserver(entries => {\n if (entries[0].isIntersecting) {\n callback();\n observer.disconnect();\n }\n });\n observer.observe(element(selector));\n};", "import { getAttributeMapping, updateAttributes } from './attributes.js';\nimport update from './update.js';\nimport validate from './validate.js';\nimport onceVisible from './onceVisible.js';\n\nexport { initialize, update, validate, onceVisible };\n\nasync function initialize({ prefix = 'db', source = '/components' } = {}) {\n const registerCache = new Set();\n const fileCache = new Set();\n\n if (typeof source !== 'string' || !Object.keys(source).length) {\n throw new Error('source option needs to be a string or an object');\n }\n\n if (typeof prefix !== 'string' || prefix === '') {\n throw new Error('prefix option needs to be a string of at least one character');\n }\n\n const inheritedStylesheets = getInheritedStylesheets();\n inPage(document.querySelector('body'));\n await fromFile(document.querySelector('body'));\n\n function inPage(root, parentId) {\n root.querySelectorAll('template').forEach(template => {\n if (!template.id && parentId) {\n template.id = `${ parentId }-child`;\n }\n\n if (!template.id) {\n console.log(template, parentId);\n throw new Error('<template> is missing a mandatory id field');\n }\n\n inPage(template.content, template.id);\n const name = template.id;\n register({ name, template });\n });\n }\n\n function fromFile(root) {\n const promises = [...root.querySelectorAll(':not(:defined)')]\n .filter(element => {\n const tagName = element.localName;\n return element.nodeType === 1 && tagName.includes('-') && tagName.startsWith(prefix);\n })\n .map(async element => {\n const name = element.localName;\n if (!fileCache.has(name)) {\n fileCache.add(name);\n const html = await fetchFromFile(name);\n const template = document.createElement('template');\n template.content.append(...html.children);\n const script = await copyScript(template);\n await fromFile(template.content);\n inPage(template.content, name);\n register({ name, template, script });\n\n function copyScript(template) {\n const script = template.content.querySelector('script');\n return new Promise(async resolve => {\n if (script) {\n const blob = new Blob([script.textContent], { type: 'text/javascript' });\n const blobUrl = URL.createObjectURL(blob);\n resolve((await import(blobUrl)).default);\n URL.revokeObjectURL(blobUrl);\n } else {\n resolve({});\n }\n });\n }\n };\n\n async function fetchFromFile(name) {\n const fileName = name.split('-').slice(1).join('-');\n const relativePath = typeof source === 'string'\n ? `${ source }/${ fileName }.html` : source[fileName];\n const response = await fetch(relativePath);\n if (!response.ok) {\n throw new Error(`Could not find component @ ${ relativePath }`);\n }\n const templateAsString = await response.text();\n const document = new DOMParser().parseFromString(templateAsString, 'text/html');\n return document.querySelector('body');\n }\n });\n\n return Promise.all(promises);\n }\n\n function register({ name, template, script }) {\n if (registerCache.has(name)) {\n return;\n }\n\n registerCache.add(name);\n\n const isFormControl = !!template.content.querySelector('input, select, textarea');\n const attributeMapping = getAttributeMapping(template.content);\n\n customElements.define(name, class extends HTMLElement {\n static observedAttributes = Object.keys(attributeMapping);\n static formAssociated = isFormControl;\n #shadow = null;\n\n constructor() {\n super();\n\n const clone = document.importNode(template.content, true);\n this.#shadow = this.attachShadow({ mode: 'open' });\n this.#shadow.adoptedStyleSheets = inheritedStylesheets;\n this.#shadow.appendChild(clone);\n\n if (isFormControl) {\n this.elementInternals = this.attachInternals();\n this.formElement = this.#shadow.querySelector('input, select, textarea');\n }\n }\n\n connectedCallback() {\n if (typeof script === 'function') {\n script(this);\n }\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (oldValue !== newValue) {\n updateAttributes({ name, value: newValue, attributeMapping, root: this.#shadow });\n }\n }\n });\n };\n\n function getInheritedStylesheets() {\n return Array.from(document.styleSheets)\n .filter(sheet => sheet?.ownerNode?.dataset?.inherit === 'true')\n .map(sheet => {\n const newSheet = new CSSStyleSheet();\n try {\n const cssText = Array.from(sheet.cssRules).map(rule => rule.cssText).join('\\n');\n newSheet.replaceSync(cssText);\n } catch (error) {\n error;\n console.error('Permission denied for sheet:', sheet.href);\n }\n return newSheet;\n });\n }\n};\n"],
5
- "mappings": "AAEA,IAAMA,EAAU,CACd,QAAS,CACP,UAAW,CAAC,SAAU,QAAS,SAAU,UAAU,EACnD,SAAU,CAAC,QAAS,OAAO,EAC3B,QAAS,CAAC,OAAO,EACjB,SAAU,CAAC,QAAS,OAAO,EAC3B,QAAS,CAAC,OAAO,EAC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AAC,EACjD,KAAKA,GAAQ,mBAAqB1B,EAClC,KAAK0B,GAAQ,YAAYC,CAAK,EAE1BJ,IACF,KAAK,iBAAmB,KAAK,gBAAgB,EAC7C,KAAK,YAAc,KAAKG,GAAQ,cAAc,yBAAyB,EAE3E,CAEA,mBAAoB,CACd,OAAOb,GAAW,YACpBA,EAAO,IAAI,CAEf,CAEA,yBAAyBN,EAAMqB,EAAUC,EAAU,CAC7CD,IAAaC,GACfC,EAAiB,CAAE,KAAAvB,EAAM,MAAOsB,EAAU,iBAAAL,EAAkB,KAAM,KAAKE,EAAQ,CAAC,CAEpF,CACF,CAAC,CACH,CAEA,SAASzB,GAA0B,CACjC,OAAO,MAAM,KAAK,SAAS,WAAW,EACnC,OAAO8B,GAASA,GAAO,WAAW,SAAS,UAAY,MAAM,EAC7D,IAAIA,GAAS,CACZ,IAAMC,EAAW,IAAI,cACrB,GAAI,CACF,IAAMC,EAAU,MAAM,KAAKF,EAAM,QAAQ,EAAE,IAAIG,GAAQA,EAAK,OAAO,EAAE,KAAK;AAAA,CAAI,EAC9EF,EAAS,YAAYC,CAAO,CAC9B,OAASE,EAAO,CAEd,QAAQ,MAAM,+BAAgCJ,EAAM,IAAI,CAC1D,CACA,OAAOC,CACT,CAAC,CACL,CACF",
6
- "names": ["mapping", "getAttributeMapping", "element", "keyValue", "excludedAttributes", "excludedElements", "binary", "results", "traverse", "tagName", "key", "tagNames", "attribute", "name", "child", "updateAttributes", "value", "attributeMapping", "root", "type", "process", "element_default", "selector", "instance", "update_default", "selector", "instance", "element_default", "idCache", "mappingCache", "renderedChildren", "idCount", "templateChild", "data", "isDate", "isArray", "updateList", "isPrimitive", "updateText", "isObject", "updateFromObject", "input", "element", "key", "value", "name", "getAttributeMapping", "attributeMapping", "updateAttributes", "match", "slot", "records", "parent", "getParent", "newChildren", "record", "index", "id", "getId", "child", "lastChild", "topLevel", "getTopLevel", "process", "setTemplateChild", "parentName", "childName", "validate_default", "selector", "instance", "element_default", "message", "validity", "minlength", "maxlength", "element", "value", "onceVisible_default", "selector", "callback", "observer", "entries", "element_default", "initialize", "prefix", "source", "registerCache", "fileCache", "inheritedStylesheets", "getInheritedStylesheets", "inPage", "fromFile", "root", "parentId", "template", "name", "register", "promises", "element", "tagName", "copyScript", "script", "resolve", "blob", "blobUrl", "html", "fetchFromFile", "fileName", "relativePath", "response", "templateAsString", "isFormControl", "attributeMapping", "getAttributeMapping", "#shadow", "clone", "oldValue", "newValue", "updateAttributes", "sheet", "newSheet", "cssText", "rule", "error"]
7
- }