mount-observer 0.0.111 → 0.1.0
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.
- package/Events.js +28 -26
- package/Events.ts +34 -30
- package/MountObserver.js +235 -520
- package/MountObserver.ts +281 -542
- package/README.md +149 -56
- package/attrCoordinates.js +93 -0
- package/attrCoordinates.ts +122 -0
- package/constants.js +6 -0
- package/constants.ts +7 -0
- package/index.js +3 -0
- package/index.ts +19 -0
- package/loadImports.js +47 -0
- package/loadImports.ts +56 -0
- package/package.json +8 -115
- package/playwright.config.ts +0 -1
- package/types.d.ts +86 -0
- package/whereAttr.js +174 -0
- package/whereAttr.ts +221 -0
- package/LICENSE +0 -21
- package/Newish.js +0 -145
- package/Newish.ts +0 -169
- package/ObsAttr.js +0 -18
- package/ObsAttr.ts +0 -18
- package/RootMutObs.js +0 -49
- package/RootMutObs.ts +0 -58
- package/Synthesizer.js +0 -125
- package/Synthesizer.ts +0 -130
- package/bindish.js +0 -15
- package/bindish.ts +0 -22
- package/compose.js +0 -148
- package/compose.ts +0 -164
- package/doCleanup.js +0 -31
- package/doCleanup.ts +0 -34
- package/getWhereAttrSelector.js +0 -83
- package/getWhereAttrSelector.ts +0 -92
- package/preloadContent.js +0 -44
- package/preloadContent.ts +0 -47
- package/readAttrs.ts +0 -60
- package/refid/README.md +0 -259
- package/refid/arr.js +0 -4
- package/refid/arr.ts +0 -4
- package/refid/camelToKebab.js +0 -4
- package/refid/camelToKebab.ts +0 -4
- package/refid/genIds.js +0 -190
- package/refid/genIds.ts +0 -177
- package/refid/getAdjRefs.js +0 -38
- package/refid/getAdjRefs.ts +0 -38
- package/refid/getContext.js +0 -13
- package/refid/getContext.ts +0 -14
- package/refid/getCount.js +0 -8
- package/refid/getCount.ts +0 -8
- package/refid/getIsh.js +0 -35
- package/refid/getIsh.ts +0 -37
- package/refid/hostish.js +0 -18
- package/refid/hostish.ts +0 -20
- package/refid/ism.js +0 -78
- package/refid/ism.ts +0 -81
- package/refid/itemprops.js +0 -60
- package/refid/itemprops.ts +0 -67
- package/refid/joinMatching.js +0 -56
- package/refid/joinMatching.ts +0 -54
- package/refid/nudge.js +0 -23
- package/refid/nudge.ts +0 -23
- package/refid/regIsh.js +0 -27
- package/refid/regIsh.ts +0 -31
- package/refid/secretKeys.js +0 -5
- package/refid/secretKeys.ts +0 -5
- package/refid/splitRefs.js +0 -6
- package/refid/splitRefs.ts +0 -6
- package/refid/stdVal.js +0 -15
- package/refid/stdVal.ts +0 -15
- package/refid/via.js +0 -114
- package/refid/via.ts +0 -113
- package/slotkin/affine.js +0 -39
- package/slotkin/affine.ts +0 -46
- package/slotkin/beKindred.js +0 -45
- package/slotkin/beKindred.ts +0 -55
- package/slotkin/getBreadth.js +0 -19
- package/slotkin/getBreadth.ts +0 -21
- package/slotkin/getFrag.js +0 -22
- package/slotkin/getFrag.ts +0 -21
- package/slotkin/toQuery.js +0 -12
- package/slotkin/toQuery.ts +0 -13
- package/slotkin/wrap.js +0 -13
- package/slotkin/wrap.ts +0 -18
- package/ts-refs/LICENSE +0 -21
- package/ts-refs/README.md +0 -18
- package/ts-refs/be-a-beacon/types.d.ts +0 -22
- package/ts-refs/be-alit/types.d.ts +0 -1
- package/ts-refs/be-based/types.d.ts +0 -32
- package/ts-refs/be-bound/types.d.ts +0 -65
- package/ts-refs/be-buttoned-up/types.d.ts +0 -21
- package/ts-refs/be-calculating/types.d.ts +0 -57
- package/ts-refs/be-clonable/types.d.ts +0 -28
- package/ts-refs/be-committed/types.d.ts +0 -26
- package/ts-refs/be-consoling/types.d.ts +0 -25
- package/ts-refs/be-counted/types.d.ts +0 -88
- package/ts-refs/be-delible/types.d.ts +0 -26
- package/ts-refs/be-directive/types.d.ts +0 -43
- package/ts-refs/be-dispatching/types.d.ts +0 -41
- package/ts-refs/be-elevating/types.d.ts +0 -55
- package/ts-refs/be-enhanced/types.d.ts +0 -32
- package/ts-refs/be-enhancing/types.d.ts +0 -31
- package/ts-refs/be-evanescent/types.d.ts +0 -20
- package/ts-refs/be-eventing/types.d.ts +0 -27
- package/ts-refs/be-exportable/types.d.ts +0 -26
- package/ts-refs/be-fetching/types.d.ts +0 -73
- package/ts-refs/be-flashy/types.d.ts +0 -27
- package/ts-refs/be-formalizing/types.d.ts +0 -29
- package/ts-refs/be-formidable/types.d.ts +0 -64
- package/ts-refs/be-giddy/types.d.ts +0 -26
- package/ts-refs/be-gingerly/types.d.ts +0 -19
- package/ts-refs/be-gone/types.d.ts +0 -24
- package/ts-refs/be-hashing-out/types.d.ts +0 -22
- package/ts-refs/be-hive/types.d.ts +0 -18
- package/ts-refs/be-imbued/types.d.ts +0 -30
- package/ts-refs/be-included/types.d.ts +0 -20
- package/ts-refs/be-inclusive/types.d.ts +0 -30
- package/ts-refs/be-intersectional/types.d.ts +0 -37
- package/ts-refs/be-intl/types.d.ts +0 -28
- package/ts-refs/be-invoking/types.d.ts +0 -28
- package/ts-refs/be-joining/types.d.ts +0 -26
- package/ts-refs/be-kvetching/types.d.ts +0 -24
- package/ts-refs/be-lazy/types.d.ts +0 -29
- package/ts-refs/be-literate/types.d.ts +0 -29
- package/ts-refs/be-mediating/types.d.ts +0 -34
- package/ts-refs/be-methodical/types.d.ts +0 -20
- package/ts-refs/be-modding/types.d.ts +0 -18
- package/ts-refs/be-observant/types.d.ts +0 -27
- package/ts-refs/be-observing/types.d.ts +0 -84
- package/ts-refs/be-parsed/types.d.ts +0 -19
- package/ts-refs/be-parsing/types.d.ts +0 -37
- package/ts-refs/be-persistent/types.d.ts +0 -66
- package/ts-refs/be-propagating/types.d.ts +0 -26
- package/ts-refs/be-reformable/types.d.ts +0 -48
- package/ts-refs/be-render-neutral/types.d.ts +0 -31
- package/ts-refs/be-scoped/types.d.ts +0 -24
- package/ts-refs/be-sharing/types.d.ts +0 -17
- package/ts-refs/be-switched/types.d.ts +0 -155
- package/ts-refs/be-typed/types.d.ts +0 -36
- package/ts-refs/be-value-added/types.d.ts +0 -34
- package/ts-refs/be-valued/types.d.ts +0 -22
- package/ts-refs/be-written/types.d.ts +0 -59
- package/ts-refs/css-charts/types.d.ts +0 -38
- package/ts-refs/css-echarts/types.d.ts +0 -13
- package/ts-refs/data-props/types.d.ts +0 -27
- package/ts-refs/do-inc/types.d.ts +0 -28
- package/ts-refs/do-invoke/types.d.ts +0 -28
- package/ts-refs/do-toggle/types.d.ts +0 -27
- package/ts-refs/em-bower/types.d.ts +0 -18
- package/ts-refs/fetch-for/types.d.ts +0 -37
- package/ts-refs/folder-picker/types.d.ts +0 -43
- package/ts-refs/for-fetch/doc.d.ts +0 -98
- package/ts-refs/for-fetch/types.d.ts +0 -83
- package/ts-refs/mount-observer/types.d.ts +0 -248
- package/ts-refs/mt-si/types.d.ts +0 -21
- package/ts-refs/per-each/types.d.ts +0 -51
- package/ts-refs/soak-up/types.d.ts +0 -36
- package/ts-refs/trans-render/XV/types.d.ts +0 -69
- package/ts-refs/trans-render/asmr/types.d.ts +0 -138
- package/ts-refs/trans-render/be/types.d.ts +0 -190
- package/ts-refs/trans-render/dss/types.d.ts +0 -57
- package/ts-refs/trans-render/froop/types.d.ts +0 -416
- package/ts-refs/trans-render/funions/types.d.ts +0 -12
- package/ts-refs/trans-render/lib/mixins/types.d.ts +0 -42
- package/ts-refs/trans-render/lib/prs/types.d.ts +0 -40
- package/ts-refs/trans-render/lib/types.d.ts +0 -489
- package/ts-refs/trans-render/types.d.ts +0 -583
- package/ts-refs/wc-info/SimpleWCInfo.d.ts +0 -15
- package/ts-refs/when-resolved/types.d.ts +0 -30
- package/ts-refs/xp-as/types.d.ts +0 -20
- package/ts-refs/xtal-element/types.d.ts +0 -43
- package/ts-refs/xtal-frappe-chart/types.d.ts +0 -193
- package/upShadowSearch.js +0 -25
- package/upShadowSearch.ts +0 -23
- package/waitForEvent.js +0 -12
- package/waitForEvent.ts +0 -13
- package/waitForIsh.js +0 -21
- package/waitForIsh.ts +0 -20
package/doCleanup.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export function doCleanup(htmlSrc, clone, options = {
|
|
2
|
-
removeInner: '[itemprop]:not([itemscope])',
|
|
3
|
-
removeOuter: '[itemprop][itemscope]'
|
|
4
|
-
}) {
|
|
5
|
-
const removeInner = htmlSrc.getAttribute('remove-inner') || options.removeInner;
|
|
6
|
-
if (removeInner) {
|
|
7
|
-
const removeInnerEls = clone.querySelectorAll(removeInner);
|
|
8
|
-
for (const removeInnerEl of removeInnerEls) {
|
|
9
|
-
if ('href' in removeInnerEl) {
|
|
10
|
-
removeInnerEl.href = '';
|
|
11
|
-
}
|
|
12
|
-
else if ('value' in removeInnerEl) {
|
|
13
|
-
removeInnerEl.value = '';
|
|
14
|
-
}
|
|
15
|
-
else if ('datetime' in removeInnerEl) {
|
|
16
|
-
removeInnerEl.datetime = '';
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
//any other exceptions?
|
|
20
|
-
removeInnerEl.textContent = '';
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const removeOuter = htmlSrc.getAttribute('remove-outer') || options.removeOuter;
|
|
25
|
-
if (removeOuter) {
|
|
26
|
-
const removeOuterEls = clone.querySelectorAll(removeOuter);
|
|
27
|
-
for (const removeOuterEl of removeOuterEls) {
|
|
28
|
-
removeOuterEl.remove();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
package/doCleanup.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
interface doCleanUpOptions {
|
|
2
|
-
removeInner?: string;
|
|
3
|
-
removeOuter?: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function doCleanup(htmlSrc: HTMLElement, clone: DocumentFragment, options: doCleanUpOptions = {
|
|
7
|
-
removeInner: '[itemprop]:not([itemscope])',
|
|
8
|
-
removeOuter: '[itemprop][itemscope]'
|
|
9
|
-
}){
|
|
10
|
-
const removeInner = htmlSrc.getAttribute('remove-inner') || options.removeInner;
|
|
11
|
-
if(removeInner){
|
|
12
|
-
const removeInnerEls = clone.querySelectorAll(removeInner);
|
|
13
|
-
for(const removeInnerEl of removeInnerEls){
|
|
14
|
-
if('href' in removeInnerEl){
|
|
15
|
-
removeInnerEl.href = '';
|
|
16
|
-
} else if ('value' in removeInnerEl){
|
|
17
|
-
removeInnerEl.value = '';
|
|
18
|
-
}else if('datetime' in removeInnerEl){
|
|
19
|
-
removeInnerEl.datetime = '';
|
|
20
|
-
}else{
|
|
21
|
-
//any other exceptions?
|
|
22
|
-
removeInnerEl.textContent = '';
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const removeOuter = htmlSrc.getAttribute('remove-outer') || options.removeOuter;
|
|
27
|
-
if(removeOuter){
|
|
28
|
-
const removeOuterEls = clone.querySelectorAll(removeOuter);
|
|
29
|
-
for(const removeOuterEl of removeOuterEls){
|
|
30
|
-
removeOuterEl.remove();
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}
|
package/getWhereAttrSelector.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
export async function getWhereAttrSelector(whereAttr, withoutAttrs) {
|
|
2
|
-
const { hasBase, hasBranchIn, hasRootIn } = whereAttr;
|
|
3
|
-
let fullListOfAttrs = [];
|
|
4
|
-
const partitionedAttrs = [];
|
|
5
|
-
if (hasBase !== undefined) {
|
|
6
|
-
const hasRootInGuaranteed = hasRootIn || [{
|
|
7
|
-
start: '',
|
|
8
|
-
context: 'Both'
|
|
9
|
-
}];
|
|
10
|
-
let prefixLessMatches = [];
|
|
11
|
-
const hasBaseIsString = typeof hasBase === 'string';
|
|
12
|
-
const baseSelector = hasBaseIsString ? hasBase : hasBase[1];
|
|
13
|
-
const rootToBaseDelimiter = hasBaseIsString ? '-' : hasBase[0];
|
|
14
|
-
if (hasBranchIn !== undefined) {
|
|
15
|
-
let baseToBranchDelimiter = '-';
|
|
16
|
-
let branches;
|
|
17
|
-
if (hasBranchIn.length === 2 && Array.isArray(hasBranchIn[1])) {
|
|
18
|
-
baseToBranchDelimiter = hasBranchIn[0];
|
|
19
|
-
branches = hasBranchIn[1];
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
branches = hasBranchIn;
|
|
23
|
-
}
|
|
24
|
-
prefixLessMatches = branches.map(x => ({
|
|
25
|
-
rootToBaseDelimiter,
|
|
26
|
-
base: baseSelector,
|
|
27
|
-
baseToBranchDelimiter: x ? baseToBranchDelimiter : '',
|
|
28
|
-
branch: x
|
|
29
|
-
}));
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
prefixLessMatches.push({
|
|
33
|
-
rootToBaseDelimiter,
|
|
34
|
-
base: baseSelector,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
for (const rootCnfg of hasRootInGuaranteed) {
|
|
38
|
-
const { start } = rootCnfg;
|
|
39
|
-
for (const match of prefixLessMatches) {
|
|
40
|
-
const { base, baseToBranchDelimiter, branch, rootToBaseDelimiter } = match;
|
|
41
|
-
let branchIdx = 0;
|
|
42
|
-
for (const prefixLessMatch of prefixLessMatches) {
|
|
43
|
-
const { base, baseToBranchDelimiter, branch } = prefixLessMatch;
|
|
44
|
-
const startAndRootToBaseDelimiter = start ? `${start}${rootToBaseDelimiter}` : '';
|
|
45
|
-
//TODO: could probably reduce the size of the code below
|
|
46
|
-
if (branch) {
|
|
47
|
-
//will always have branch?
|
|
48
|
-
const name = `${startAndRootToBaseDelimiter}${base}${baseToBranchDelimiter}${branch}`;
|
|
49
|
-
fullListOfAttrs.push(name);
|
|
50
|
-
partitionedAttrs.push({
|
|
51
|
-
root: start,
|
|
52
|
-
name,
|
|
53
|
-
base,
|
|
54
|
-
branch,
|
|
55
|
-
branchIdx,
|
|
56
|
-
rootCnfg
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const name = `${startAndRootToBaseDelimiter}${base}`;
|
|
61
|
-
fullListOfAttrs.push(name);
|
|
62
|
-
partitionedAttrs.push({
|
|
63
|
-
root: start,
|
|
64
|
-
name,
|
|
65
|
-
base,
|
|
66
|
-
rootCnfg,
|
|
67
|
-
branchIdx
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
branchIdx++;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
fullListOfAttrs = Array.from(new Set(fullListOfAttrs));
|
|
76
|
-
const listOfSelectors = fullListOfAttrs.map(s => `${withoutAttrs}[${s}]`);
|
|
77
|
-
const calculatedSelector = listOfSelectors.join(',');
|
|
78
|
-
return {
|
|
79
|
-
fullListOfAttrs,
|
|
80
|
-
calculatedSelector,
|
|
81
|
-
partitionedAttrs,
|
|
82
|
-
};
|
|
83
|
-
}
|
package/getWhereAttrSelector.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {AttrParts, RootCnfg, WhereAttr} from './ts-refs/mount-observer/types';
|
|
2
|
-
export async function getWhereAttrSelector(whereAttr: WhereAttr, withoutAttrs: string){
|
|
3
|
-
const {hasBase, hasBranchIn, hasRootIn} = whereAttr;
|
|
4
|
-
|
|
5
|
-
let fullListOfAttrs: Array<string> = [];
|
|
6
|
-
const partitionedAttrs: Array<AttrParts> = [];
|
|
7
|
-
if(hasBase !== undefined){
|
|
8
|
-
const hasRootInGuaranteed: Array<RootCnfg> = hasRootIn || [{
|
|
9
|
-
start: '',
|
|
10
|
-
context: 'Both'
|
|
11
|
-
} as RootCnfg];
|
|
12
|
-
|
|
13
|
-
let prefixLessMatches: Array<{
|
|
14
|
-
rootToBaseDelimiter: string,
|
|
15
|
-
base: string,
|
|
16
|
-
branch?: string,
|
|
17
|
-
leaf?: string //todo,
|
|
18
|
-
baseToBranchDelimiter?: string,
|
|
19
|
-
}> = [];
|
|
20
|
-
const hasBaseIsString = typeof hasBase === 'string';
|
|
21
|
-
const baseSelector = hasBaseIsString ? hasBase : hasBase[1];
|
|
22
|
-
const rootToBaseDelimiter = hasBaseIsString ? '-' : hasBase[0];
|
|
23
|
-
if(hasBranchIn !== undefined){
|
|
24
|
-
let baseToBranchDelimiter = '-';
|
|
25
|
-
let branches: Array<string> | undefined;
|
|
26
|
-
if(hasBranchIn.length === 2 && Array.isArray(hasBranchIn[1])){
|
|
27
|
-
baseToBranchDelimiter = hasBranchIn[0];
|
|
28
|
-
branches = hasBranchIn[1];
|
|
29
|
-
}else{
|
|
30
|
-
branches = hasBranchIn as Array<string>;
|
|
31
|
-
}
|
|
32
|
-
prefixLessMatches = branches.map(x => ({
|
|
33
|
-
rootToBaseDelimiter,
|
|
34
|
-
base: baseSelector,
|
|
35
|
-
baseToBranchDelimiter: x ? baseToBranchDelimiter : '',
|
|
36
|
-
branch: x
|
|
37
|
-
}));
|
|
38
|
-
}else{
|
|
39
|
-
prefixLessMatches.push({
|
|
40
|
-
rootToBaseDelimiter,
|
|
41
|
-
base: baseSelector,
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
for(const rootCnfg of hasRootInGuaranteed){
|
|
45
|
-
const {start} = rootCnfg;
|
|
46
|
-
for(const match of prefixLessMatches){
|
|
47
|
-
const {base, baseToBranchDelimiter, branch, rootToBaseDelimiter} = match;
|
|
48
|
-
let branchIdx = 0;
|
|
49
|
-
for(const prefixLessMatch of prefixLessMatches){
|
|
50
|
-
const {base, baseToBranchDelimiter, branch} = prefixLessMatch;
|
|
51
|
-
const startAndRootToBaseDelimiter = start ? `${start}${rootToBaseDelimiter}` : '';
|
|
52
|
-
//TODO: could probably reduce the size of the code below
|
|
53
|
-
if(branch){
|
|
54
|
-
//will always have branch?
|
|
55
|
-
const name = `${startAndRootToBaseDelimiter}${base}${baseToBranchDelimiter}${branch}`
|
|
56
|
-
fullListOfAttrs.push(name);
|
|
57
|
-
partitionedAttrs.push({
|
|
58
|
-
root: start,
|
|
59
|
-
name,
|
|
60
|
-
base,
|
|
61
|
-
branch,
|
|
62
|
-
branchIdx,
|
|
63
|
-
rootCnfg
|
|
64
|
-
});
|
|
65
|
-
}else{
|
|
66
|
-
const name = `${startAndRootToBaseDelimiter}${base}`;
|
|
67
|
-
fullListOfAttrs.push(name);
|
|
68
|
-
partitionedAttrs.push({
|
|
69
|
-
root: start,
|
|
70
|
-
name,
|
|
71
|
-
base,
|
|
72
|
-
rootCnfg,
|
|
73
|
-
branchIdx
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
branchIdx++;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
fullListOfAttrs = Array.from(new Set(fullListOfAttrs));
|
|
84
|
-
const listOfSelectors = fullListOfAttrs.map(s => `${withoutAttrs}[${s}]`);
|
|
85
|
-
const calculatedSelector = listOfSelectors.join(',');
|
|
86
|
-
return {
|
|
87
|
-
fullListOfAttrs,
|
|
88
|
-
calculatedSelector,
|
|
89
|
-
partitionedAttrs,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
}
|
package/preloadContent.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { upShadowSearch } from './upShadowSearch.js';
|
|
2
|
-
const remoteTemplElSym = Symbol.for('du3y+tfsAUGFHMG/iHZiMQ');
|
|
3
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'remoteContent', {
|
|
4
|
-
get() {
|
|
5
|
-
const templ = this;
|
|
6
|
-
const src = templ.getAttribute('src');
|
|
7
|
-
if (src === null) {
|
|
8
|
-
const head = document.head;
|
|
9
|
-
if (window[remoteTemplElSym] === undefined) {
|
|
10
|
-
window[remoteTemplElSym] = 0;
|
|
11
|
-
}
|
|
12
|
-
const id = templ.id || `mount-observer-${window[remoteTemplElSym]++}`;
|
|
13
|
-
const sourceTempl = document.createElement('template');
|
|
14
|
-
sourceTempl.id = '' + id;
|
|
15
|
-
sourceTempl.content.appendChild(templ.content);
|
|
16
|
-
head.append(sourceTempl);
|
|
17
|
-
templ.innerHTML = '';
|
|
18
|
-
templ.setAttribute('src', `#${id}`);
|
|
19
|
-
templ.setAttribute('rel', 'preload');
|
|
20
|
-
templ[remoteTemplElSym] = new WeakRef(sourceTempl);
|
|
21
|
-
return sourceTempl.content;
|
|
22
|
-
}
|
|
23
|
-
{
|
|
24
|
-
const test = templ[remoteTemplElSym]?.deref();
|
|
25
|
-
if (test !== undefined)
|
|
26
|
-
return test.content;
|
|
27
|
-
if (templ.getAttribute('rel') !== 'preload')
|
|
28
|
-
throw 'NI';
|
|
29
|
-
const isIntraDoc = src[0] === '#';
|
|
30
|
-
if (!isIntraDoc)
|
|
31
|
-
throw 'NI';
|
|
32
|
-
const id = src.substring(1);
|
|
33
|
-
const remoteTempl = upShadowSearch(templ, id);
|
|
34
|
-
if (!(remoteTempl instanceof HTMLTemplateElement))
|
|
35
|
-
throw 404; //not found
|
|
36
|
-
templ[remoteTemplElSym] = new WeakRef(remoteTempl);
|
|
37
|
-
return remoteTempl.content;
|
|
38
|
-
//templ.dispatchEvent(new Event('load'));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
export function preloadContent(templ) {
|
|
43
|
-
const content = templ.remoteContent;
|
|
44
|
-
}
|
package/preloadContent.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {TemplateWithRemoteContent} from './ts-refs/mount-observer/types.js';
|
|
2
|
-
import {upShadowSearch} from './upShadowSearch.js';
|
|
3
|
-
const remoteTemplElSym = Symbol.for('du3y+tfsAUGFHMG/iHZiMQ');
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(HTMLTemplateElement.prototype, 'remoteContent', {
|
|
6
|
-
get(){
|
|
7
|
-
const templ = this as HTMLTemplateElement;
|
|
8
|
-
const src = templ.getAttribute('src');
|
|
9
|
-
if(src === null){
|
|
10
|
-
const head = document.head;
|
|
11
|
-
if((<any>window)[remoteTemplElSym] === undefined ){
|
|
12
|
-
(<any>window)[remoteTemplElSym] = 0;
|
|
13
|
-
}
|
|
14
|
-
const id = templ.id || `mount-observer-${(<any>window)[remoteTemplElSym]++}`;
|
|
15
|
-
const sourceTempl = document.createElement('template');
|
|
16
|
-
sourceTempl.id = '' + id;
|
|
17
|
-
sourceTempl.content.appendChild(templ.content);
|
|
18
|
-
head.append(sourceTempl);
|
|
19
|
-
templ.innerHTML = '';
|
|
20
|
-
templ.setAttribute('src', `#${id}`);
|
|
21
|
-
templ.setAttribute('rel', 'preload');
|
|
22
|
-
(<any>templ)[remoteTemplElSym] = new WeakRef(sourceTempl);
|
|
23
|
-
return sourceTempl.content;
|
|
24
|
-
}
|
|
25
|
-
{
|
|
26
|
-
const test = (<any>templ)[remoteTemplElSym]?.deref();
|
|
27
|
-
if(test !== undefined) return test.content;
|
|
28
|
-
if(templ.getAttribute('rel') !== 'preload') throw 'NI';
|
|
29
|
-
const isIntraDoc = src[0] === '#';
|
|
30
|
-
if(!isIntraDoc) throw 'NI';
|
|
31
|
-
const id = src.substring(1);
|
|
32
|
-
const remoteTempl = upShadowSearch(templ, id);
|
|
33
|
-
if(!(remoteTempl instanceof HTMLTemplateElement)) throw 404; //not found
|
|
34
|
-
(<any>templ)[remoteTemplElSym] = new WeakRef(remoteTempl);
|
|
35
|
-
return remoteTempl.content;
|
|
36
|
-
//templ.dispatchEvent(new Event('load'));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
export function preloadContent(
|
|
43
|
-
templ: HTMLTemplateElement,
|
|
44
|
-
) {
|
|
45
|
-
const content = (<any>templ).remoteContent;
|
|
46
|
-
|
|
47
|
-
}
|
package/readAttrs.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { AttrChangeInfo, AttrParts, MountInit } from "./ts-refs/mount-observer/types";
|
|
2
|
-
|
|
3
|
-
export function readAttrs(
|
|
4
|
-
match: Element, mountInit: MountInit, branchIndexes?: Set<number>,
|
|
5
|
-
fullListOfEnhancementAttrs?: string[],
|
|
6
|
-
attrParts?: AttrParts[],
|
|
7
|
-
){
|
|
8
|
-
//TODO: externalize
|
|
9
|
-
const fullListOfAttrs = fullListOfEnhancementAttrs;
|
|
10
|
-
const attrChangeInfos: Array<AttrChangeInfo> = [];
|
|
11
|
-
const oldValue = null;
|
|
12
|
-
if(fullListOfAttrs !== undefined){
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
for(let idx = 0, ii = fullListOfAttrs.length; idx < ii; idx++){
|
|
16
|
-
const parts = attrParts![idx];
|
|
17
|
-
const {branchIdx} = parts;
|
|
18
|
-
if(branchIndexes !== undefined){
|
|
19
|
-
if(!branchIndexes.has(branchIdx)) continue;
|
|
20
|
-
}
|
|
21
|
-
const name = fullListOfAttrs[idx];
|
|
22
|
-
|
|
23
|
-
const newValue = match.getAttribute(name);
|
|
24
|
-
|
|
25
|
-
attrChangeInfos.push({
|
|
26
|
-
idx,
|
|
27
|
-
isSOfTAttr: false,
|
|
28
|
-
newValue,
|
|
29
|
-
oldValue,
|
|
30
|
-
name,
|
|
31
|
-
parts
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
const {observedAttrsWhenMounted} = mountInit;
|
|
37
|
-
if(observedAttrsWhenMounted !== undefined){
|
|
38
|
-
for(const observedAttr of observedAttrsWhenMounted){
|
|
39
|
-
const attrIsString = typeof observedAttr === 'string';
|
|
40
|
-
const name = attrIsString ? observedAttr : observedAttr.name;
|
|
41
|
-
let mapsTo: string | undefined;
|
|
42
|
-
let newValue = match.getAttribute(name);
|
|
43
|
-
if(!attrIsString){
|
|
44
|
-
const {customParser, instanceOf, mapsTo: mt, valIfNull} = observedAttr;
|
|
45
|
-
if(instanceOf || customParser) throw 'NI';
|
|
46
|
-
if(newValue === null) newValue = valIfNull;
|
|
47
|
-
mapsTo = mt;
|
|
48
|
-
}
|
|
49
|
-
attrChangeInfos.push({
|
|
50
|
-
isSOfTAttr: true,
|
|
51
|
-
newValue,
|
|
52
|
-
oldValue,
|
|
53
|
-
name,
|
|
54
|
-
mapsTo
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return attrChangeInfos;
|
|
60
|
-
}
|
package/refid/README.md
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
# Auto generated id polyfill
|
|
2
|
-
|
|
3
|
-
*mount-observer* has a polyfill for [this proposal](https://github.com/whatwg/html/issues/11585), but with some differences due to the limited ability a polyfill can provide compared to the platform.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
Any DOM fragment that gets observed by the MountObserver class instance will automatically apply the rules discussed below.
|
|
8
|
-
|
|
9
|
-
In the absence of such observing, call:
|
|
10
|
-
|
|
11
|
-
```JavaScript
|
|
12
|
-
import {genIds} from 'mount-observer/refid/genIds.js';
|
|
13
|
-
genIds(oElementContainer);
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## Activation
|
|
17
|
-
|
|
18
|
-
To activate a scoped id generation, add attribute -id to the last streamed element inside either the fieldset element, or an element adorned by the itemscope attribute, or the (Shadow) root.
|
|
19
|
-
|
|
20
|
-
If the -id attribute is not added to the last streamed element, but elsewhere, then the functionality will likely work the same, but may possibly miss some elements after the attribute, in the unlikely event that the auto generated id's are created prior to some additional elements streaming in.
|
|
21
|
-
|
|
22
|
-
## Example 1
|
|
23
|
-
|
|
24
|
-
```html
|
|
25
|
-
<fieldset disabled>
|
|
26
|
-
<label>
|
|
27
|
-
LHS: <input data-id={{lhs}}>
|
|
28
|
-
</label>
|
|
29
|
-
|
|
30
|
-
<label for=rhs>
|
|
31
|
-
RHS: <input data-id={{rhs}}>
|
|
32
|
-
</label>
|
|
33
|
-
|
|
34
|
-
<template -id defer-🎚️ 🎚️='on if isEqual, based on #{{lhs}} and #{{rhs}}.'>
|
|
35
|
-
<div>LHS === RHS</div>
|
|
36
|
-
</template>
|
|
37
|
-
</fieldset>
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
adjusts the DOM so as to become:
|
|
41
|
-
|
|
42
|
-
```html
|
|
43
|
-
<fieldset>
|
|
44
|
-
<label>
|
|
45
|
-
LHS: <input id=gid-0 data-id=lhs>
|
|
46
|
-
</label>
|
|
47
|
-
|
|
48
|
-
<label for=rhs>
|
|
49
|
-
RHS: <input id=gid-1 data-id=rhs>
|
|
50
|
-
</label>
|
|
51
|
-
|
|
52
|
-
<template 🎚️='on if isEqual, based on #gid-0 and #gid-1.'>
|
|
53
|
-
<div>LHS === RHS</div>
|
|
54
|
-
</template>
|
|
55
|
-
</fieldset>
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Note that the numbers after gid- will vary depending on previous DOM elements that may have been processed by the ID generator.
|
|
59
|
-
|
|
60
|
-
Note the use of the "disabled" attribute on the fieldset element, and the defer-🎚️ attributes, both of which get removed after the id auto generation completes. The idea is that while the live DOM tree has these attributes, allowing user interactivity could be problematic before the id's are generated, so at a minimum, we should disable input elements, and prevent [enhancements from loading](https://github.com/WICG/webcomponents/issues/1000) until the id connection is established, scoped preferably by fieldset elements, or itemscope attributes, or the root document as a last resort.
|
|
61
|
-
|
|
62
|
-
The reason why we keep the names lhs, rhs in the data-id attribute after stripping away curly braces and other side-effect inducing symbols, is that some libraries will want to refer to the name that was used to generate the id's.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
## Creating id references with global or built in attributes
|
|
66
|
-
|
|
67
|
-
Again, because 1. unlike the platform, we can't manipulate the server-streamed DOM before the browser sees it, and 2. we don't want to "confuse" the browser by creating nonsensical id reference connections that aren't valid, even temporarily, this polyfill opts to use data-* attributes as a way of staging the dynamic attribute adjustments. So for example:
|
|
68
|
-
|
|
69
|
-
```html
|
|
70
|
-
<fieldset disabled>
|
|
71
|
-
<scratch-box>
|
|
72
|
-
<label slot=label data-for={{createDemo}}>Create demo</label>
|
|
73
|
-
<input data-id="{{@ createDemo}}" type=checkbox>
|
|
74
|
-
</scratch-box>
|
|
75
|
-
<scratch-box>
|
|
76
|
-
<label slot=label data-for={{writeArticle}}>Write article</label>
|
|
77
|
-
<input data-id="{{@ writeArticle}}" type=checkbox>
|
|
78
|
-
</scratch-box>
|
|
79
|
-
<scratch-box>
|
|
80
|
-
<label slot=label data-for={{exercise}}>Exercise</label>
|
|
81
|
-
<input -id data-id="{{@ exercise}}" type=checkbox>
|
|
82
|
-
</scratch-box>
|
|
83
|
-
</fieldset>
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
becomes
|
|
87
|
-
|
|
88
|
-
```html
|
|
89
|
-
<fieldset disabled>
|
|
90
|
-
<scratch-box enh-be-importing=scratch-box/root.mjs>
|
|
91
|
-
<label slot=label for=gid-0>Create demo</label>
|
|
92
|
-
<input id=gid-0 name=createDemo data-id=createDemo type=checkbox>
|
|
93
|
-
</scratch-box>
|
|
94
|
-
<scratch-box>
|
|
95
|
-
<label slot=label for=gid-1>Write article</label>
|
|
96
|
-
<input id=gid-1 name=writeArticle data-id=writeArticle type=checkbox>
|
|
97
|
-
</scratch-box>
|
|
98
|
-
<scratch-box>
|
|
99
|
-
<label slot=label for=gid-2>Exercise</label>
|
|
100
|
-
<input id=gid-2 name=exercise data-id=exercise type=checkbox>
|
|
101
|
-
</scratch-box>
|
|
102
|
-
</fieldset>
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
It is often the case that the name we want to use to auto generate the unique id's will match the "name" attribute we want to assign the element, and/or the itemprop and/or the class and/or the part. This can be done in a few ways.
|
|
106
|
-
|
|
107
|
-
## Side Effects from dynamic data-id attribute
|
|
108
|
-
|
|
109
|
-
```html
|
|
110
|
-
<form>
|
|
111
|
-
<fieldset disabled>
|
|
112
|
-
<label>
|
|
113
|
-
LHS: <input class=my-class data-id="{{@. lhs}}">
|
|
114
|
-
</label>
|
|
115
|
-
|
|
116
|
-
<label for=rhs>
|
|
117
|
-
RHS: <span contenteditable part=my-part data-id="{{|% rhs}}">
|
|
118
|
-
</label>
|
|
119
|
-
|
|
120
|
-
<template -id defer-🎚️ 🎚️='on if isEqual, based on #{{lhs}} and #{{rhs}}.'>
|
|
121
|
-
<div>LHS === RHS</div>
|
|
122
|
-
</template>
|
|
123
|
-
</fieldset>
|
|
124
|
-
</form>
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
results in
|
|
128
|
-
|
|
129
|
-
```html
|
|
130
|
-
<form>
|
|
131
|
-
<fieldset>
|
|
132
|
-
<label>
|
|
133
|
-
LHS: <input name=lhs class="my-part lhs" id=gid-0 data-id=lhs>
|
|
134
|
-
</label>
|
|
135
|
-
|
|
136
|
-
<label for=rhs>
|
|
137
|
-
RHS: <span itemprop=rhs part="my-part rhs" id=gid-1 data-id=rhs>
|
|
138
|
-
</label>
|
|
139
|
-
|
|
140
|
-
<template 🎚️='on if isEqual, based on #gid-0 and #gid-1.'>
|
|
141
|
-
<div>LHS === RHS</div>
|
|
142
|
-
</template>
|
|
143
|
-
</fieldset>
|
|
144
|
-
</form>
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
So we are using some special symbols to correspond with key attributes:
|
|
148
|
-
|
|
149
|
-
Symbol | Translates to | Connection / meaning |
|
|
150
|
-
|--------|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
151
|
-
| # | id | # used by css for id, also bookmarks in urls that points to id's |
|
|
152
|
-
| \| | itemprop | "Pipe" is kind of close to itemprop, and is half of a dollar sign, and it kind of looks like an I |
|
|
153
|
-
| @ | name | Second letter of name. Also, common in social media sites/github to type this letter in order to select someone's name. |
|
|
154
|
-
| $ | itemscope + itemprop | Combination of S for Scope and Pipe which resembles itemprop a bit |
|
|
155
|
-
| % | part | Starts with p, percent is used for indicating what proportion something is. |
|
|
156
|
-
| . | class | css selector |
|
|
157
|
-
|
|
158
|
-
These match the symbols used in the [template instantiation productivity proposal](https://github.com/WICG/webcomponents/issues/1013#issuecomment-2257557589).
|
|
159
|
-
|
|
160
|
-
The examples that follow go in the opposite direction -- we "infer" the id generating name based on either the name of the element, or one of the key attributes
|
|
161
|
-
|
|
162
|
-
## By tag name
|
|
163
|
-
|
|
164
|
-
Id's based on the element name
|
|
165
|
-
|
|
166
|
-
```html
|
|
167
|
-
<ways-of-science itemscope>
|
|
168
|
-
<carrot-nosed-woman #></carrot-nosed-woman>
|
|
169
|
-
<a-duck #></a-duck>
|
|
170
|
-
<template -id defer-🎚️
|
|
171
|
-
🎚️="on based on #{{carrot-nosed-woman}}::weight-change and #{{a-duck}}::molting."
|
|
172
|
-
onchange="event.r = Math.abs(event.args[0] - event.args[1]) < 10"
|
|
173
|
-
>
|
|
174
|
-
<div>A witch!</div>
|
|
175
|
-
<div>Burn her!</div>
|
|
176
|
-
</template>
|
|
177
|
-
</ways-of-science>
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
results in:
|
|
181
|
-
|
|
182
|
-
```html
|
|
183
|
-
<ways-of-science itemscope>
|
|
184
|
-
<carrot-nosed-woman id=gid-0 data-id=carrot-nosed-woman></carrot-nosed-woman>
|
|
185
|
-
<a-duck id=gid-1 data-id=a-duck></a-duck>
|
|
186
|
-
<template
|
|
187
|
-
🎚️="on based on #gid-0::weight-change and #gid-1::molting."
|
|
188
|
-
onchange="event.r = Math.abs(event.args[0] - event.args[1]) < 10"
|
|
189
|
-
>
|
|
190
|
-
<div>A witch!</div>
|
|
191
|
-
<div>Burn her!</div>
|
|
192
|
-
</template>
|
|
193
|
-
</ways-of-science>
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
## By N@me
|
|
197
|
-
|
|
198
|
-
```html
|
|
199
|
-
<form>
|
|
200
|
-
<fieldset disabled>
|
|
201
|
-
<input name=isHappy type="checkbox" @>
|
|
202
|
-
<template -id defer-🎚️ 🎚️='on when #{{isHappy}}.'>
|
|
203
|
-
<my-content></my-content>
|
|
204
|
-
</template>
|
|
205
|
-
</fieldset>
|
|
206
|
-
</form>
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
results in:
|
|
210
|
-
|
|
211
|
-
```html
|
|
212
|
-
<form>
|
|
213
|
-
<fieldset>
|
|
214
|
-
<input name=isHappy id=gid-0 data-id=isHappy type="checkbox">
|
|
215
|
-
<template 🎚️='on when #gid-0.'>
|
|
216
|
-
<my-content></my-content>
|
|
217
|
-
</template>
|
|
218
|
-
</fieldset>
|
|
219
|
-
</form>
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
## By |temprop
|
|
223
|
-
|
|
224
|
-
```html
|
|
225
|
-
<form>
|
|
226
|
-
<fieldset disabled>
|
|
227
|
-
<data value=true itemprop=isHappy hidden |></data>
|
|
228
|
-
<template -id defer-🎚️ 🎚️='on when #{{isHappy}}.'>
|
|
229
|
-
<my-content></my-content>
|
|
230
|
-
</template>
|
|
231
|
-
</fieldset>
|
|
232
|
-
</form>
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
results in:
|
|
236
|
-
|
|
237
|
-
```html
|
|
238
|
-
<form>
|
|
239
|
-
<fieldset>
|
|
240
|
-
<data value=true data-id=isHappy id=gid-0 itemprop=isHappy hidden></data>
|
|
241
|
-
<template 🎚️='on when #gid-0.'>
|
|
242
|
-
<my-content></my-content>
|
|
243
|
-
</template>
|
|
244
|
-
</fieldset>
|
|
245
|
-
</form>
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
<!--
|
|
249
|
-
## By Itemscope
|
|
250
|
-
|
|
251
|
-
```html
|
|
252
|
-
<table>
|
|
253
|
-
<tbody>
|
|
254
|
-
<tr itemscope=myRowHandler #>
|
|
255
|
-
</tr>
|
|
256
|
-
</tbody>
|
|
257
|
-
</table>
|
|
258
|
-
```
|
|
259
|
-
-->
|
package/refid/arr.js
DELETED
package/refid/arr.ts
DELETED
package/refid/camelToKebab.js
DELETED
package/refid/camelToKebab.ts
DELETED