mount-observer 0.0.94 → 0.0.95
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/package.json
CHANGED
package/refid/genIds.js
CHANGED
|
@@ -4,12 +4,23 @@ const attrMap = {
|
|
|
4
4
|
'@': 'name',
|
|
5
5
|
'|': 'itemprop',
|
|
6
6
|
};
|
|
7
|
+
const scopeMatches = '[itemscope],fieldset';
|
|
8
|
+
export function inScope(scopeFragment, el) {
|
|
9
|
+
const closest = el.closest(scopeMatches); //TODO account for itemref?
|
|
10
|
+
if (closest === null)
|
|
11
|
+
return true;
|
|
12
|
+
if (scopeFragment === closest)
|
|
13
|
+
return true;
|
|
14
|
+
if (scopeFragment.contains(closest))
|
|
15
|
+
return false;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
7
18
|
export function genIds(enhancedElement) {
|
|
8
|
-
const {
|
|
9
|
-
if
|
|
10
|
-
|
|
19
|
+
// const {parentElement} = enhancedElement;
|
|
20
|
+
// if(parentElement === null) throw 404;
|
|
21
|
+
const scopeFragment = (enhancedElement.closest(scopeMatches) || enhancedElement.getRootNode());
|
|
11
22
|
//first find all elements with attribute #
|
|
12
|
-
const hashIds = Array.from(
|
|
23
|
+
const hashIds = Array.from(scopeFragment.querySelectorAll('[\\#]')).filter(x => inScope(scopeFragment, x));
|
|
13
24
|
const uniqueCheck = new Set();
|
|
14
25
|
for (const hi of hashIds) {
|
|
15
26
|
if (!(hi instanceof HTMLElement))
|
|
@@ -26,7 +37,7 @@ export function genIds(enhancedElement) {
|
|
|
26
37
|
hi.dataset.id = `{{${sideEffects}${localName}}}`;
|
|
27
38
|
hi.removeAttribute('#');
|
|
28
39
|
}
|
|
29
|
-
const dataIds = Array.from(
|
|
40
|
+
const dataIds = Array.from(scopeFragment.querySelectorAll('[data-id^="{{"][data-id$="}}"]')).filter(x => inScope(scopeFragment, x));
|
|
30
41
|
const ids = [];
|
|
31
42
|
for (const di of dataIds) {
|
|
32
43
|
if (!(di instanceof HTMLElement))
|
|
@@ -41,8 +52,9 @@ export function genIds(enhancedElement) {
|
|
|
41
52
|
throw 500;
|
|
42
53
|
ids.push(id);
|
|
43
54
|
}
|
|
44
|
-
const allChildren = Array.from(
|
|
45
|
-
|
|
55
|
+
const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
|
|
56
|
+
if (scopeFragment instanceof Element)
|
|
57
|
+
allChildren.push(scopeFragment);
|
|
46
58
|
const idLookup = {};
|
|
47
59
|
const base = 'gid';
|
|
48
60
|
for (const child of allChildren) {
|
|
@@ -124,7 +136,7 @@ export function genIds(enhancedElement) {
|
|
|
124
136
|
nudge(child, name);
|
|
125
137
|
}
|
|
126
138
|
}
|
|
127
|
-
if ('disabled' in
|
|
128
|
-
nudge(
|
|
139
|
+
if (scopeFragment instanceof Element && 'disabled' in scopeFragment) {
|
|
140
|
+
nudge(scopeFragment);
|
|
129
141
|
}
|
|
130
142
|
}
|
package/refid/genIds.ts
CHANGED
|
@@ -6,12 +6,23 @@ const attrMap = {
|
|
|
6
6
|
'|': 'itemprop',
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
const scopeMatches = '[itemscope],fieldset';
|
|
10
|
+
|
|
11
|
+
export function inScope(scopeFragment: DocumentFragment | Element, el: Element){
|
|
12
|
+
const closest = el.closest(scopeMatches);//TODO account for itemref?
|
|
13
|
+
if(closest === null) return true;
|
|
14
|
+
if(scopeFragment === closest) return true;
|
|
15
|
+
if(scopeFragment.contains(closest)) return false;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
|
|
9
19
|
export function genIds(enhancedElement: Element){
|
|
10
|
-
const {parentElement} = enhancedElement;
|
|
11
|
-
if(parentElement === null) throw 404;
|
|
20
|
+
// const {parentElement} = enhancedElement;
|
|
21
|
+
// if(parentElement === null) throw 404;
|
|
22
|
+
const scopeFragment = (enhancedElement.closest(scopeMatches) || enhancedElement.getRootNode()) as DocumentFragment | Element;
|
|
12
23
|
|
|
13
24
|
//first find all elements with attribute #
|
|
14
|
-
const hashIds = Array.from(
|
|
25
|
+
const hashIds = Array.from(scopeFragment.querySelectorAll('[\\#]')).filter(x => inScope(scopeFragment, x));
|
|
15
26
|
const uniqueCheck = new Set();
|
|
16
27
|
for(const hi of hashIds){
|
|
17
28
|
if(!(hi instanceof HTMLElement)) continue;
|
|
@@ -27,7 +38,7 @@ export function genIds(enhancedElement: Element){
|
|
|
27
38
|
hi.removeAttribute('#');
|
|
28
39
|
}
|
|
29
40
|
|
|
30
|
-
const dataIds = Array.from(
|
|
41
|
+
const dataIds = Array.from(scopeFragment.querySelectorAll('[data-id^="{{"][data-id$="}}"]')).filter(x => inScope(scopeFragment, x));
|
|
31
42
|
const ids: Array<string> = [];
|
|
32
43
|
for(const di of dataIds){
|
|
33
44
|
if(!(di instanceof HTMLElement)) continue;
|
|
@@ -40,8 +51,8 @@ export function genIds(enhancedElement: Element){
|
|
|
40
51
|
ids.push(id);
|
|
41
52
|
}
|
|
42
53
|
|
|
43
|
-
const allChildren = Array.from(
|
|
44
|
-
allChildren.push(
|
|
54
|
+
const allChildren = Array.from(scopeFragment.querySelectorAll('*')).filter(x => inScope(scopeFragment, x));
|
|
55
|
+
if(scopeFragment instanceof Element) allChildren.push(scopeFragment);
|
|
45
56
|
|
|
46
57
|
const idLookup: {[key: string]: string} = {};
|
|
47
58
|
const base = 'gid';
|
|
@@ -120,7 +131,7 @@ export function genIds(enhancedElement: Element){
|
|
|
120
131
|
nudge(child, name);
|
|
121
132
|
}
|
|
122
133
|
}
|
|
123
|
-
if('disabled' in
|
|
124
|
-
nudge(
|
|
134
|
+
if(scopeFragment instanceof Element && 'disabled' in scopeFragment){
|
|
135
|
+
nudge(scopeFragment);
|
|
125
136
|
}
|
|
126
137
|
}
|
|
@@ -4,7 +4,7 @@ import {BEAllProps, EMC, IEnhancement} from '../trans-render/be/types';
|
|
|
4
4
|
//import {AP as BPAP, ISignal, Actions as BPActions} from 'be-propagating/types';
|
|
5
5
|
//import {ElTypes, SignalRefType} from 'be-linked/types';
|
|
6
6
|
//import { Propagator } from "../trans-render/froop/PropSvc";
|
|
7
|
-
import {
|
|
7
|
+
import {Specifier} from '../trans-render/dss/types';
|
|
8
8
|
|
|
9
9
|
export interface Element{
|
|
10
10
|
hostish(): Promise<any>
|
|
@@ -62,7 +62,7 @@ export type SwitchStatement = string;
|
|
|
62
62
|
|
|
63
63
|
export interface OneValueSwitch{
|
|
64
64
|
ifPart: string,
|
|
65
|
-
|
|
65
|
+
specifier: Specifier,
|
|
66
66
|
req?: boolean,
|
|
67
67
|
}
|
|
68
68
|
|
|
@@ -76,8 +76,8 @@ export interface TwoPartOpStatement{
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
export interface TwoValueSwitch{
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
lhsSpecifier: Specifier,
|
|
80
|
+
rhsSpecifier: Specifier,
|
|
81
81
|
req?: boolean,
|
|
82
82
|
op?: Op,
|
|
83
83
|
lhs?: ISide,
|
|
@@ -90,7 +90,7 @@ export interface TwoValueSwitch{
|
|
|
90
90
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
export interface Dependency extends
|
|
93
|
+
export interface Dependency extends Specifier{}
|
|
94
94
|
|
|
95
95
|
export interface CanBeSwitchedOn {
|
|
96
96
|
switchedOn?: boolean,
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Scope } from '../lib/types'
|
|
2
|
-
import { CSSQuery } from '../types';
|
|
3
|
-
|
|
4
1
|
export type ID = `#${string}`;
|
|
5
2
|
export type Host = `:host()`;
|
|
6
3
|
export type Hostish = ``;
|
|
@@ -20,22 +17,22 @@ export type asOptions =
|
|
|
20
17
|
| 'boolean|number'
|
|
21
18
|
;
|
|
22
19
|
export type MindReadType = ``;
|
|
23
|
-
export type TypeQualifier =
|
|
20
|
+
export type TypeQualifier = `-as-${asOptions}`;
|
|
24
21
|
|
|
25
22
|
export type ValExpression = `${PropPath | ConstVal | MindReadProp}${TypeQualifier | MindReadType}`;
|
|
26
23
|
|
|
27
24
|
export type MindReadEvent = ``;
|
|
28
25
|
|
|
29
|
-
export type
|
|
26
|
+
export type EventPart = `::${string}`;
|
|
30
27
|
|
|
31
|
-
export type DSS = `${Target}${ValExpression}${
|
|
28
|
+
export type DSS = `${Target}${ValExpression}${EventPart}`;
|
|
32
29
|
|
|
33
30
|
|
|
34
31
|
export interface Specifier {
|
|
35
32
|
id?: string,
|
|
36
33
|
prop?: string,
|
|
37
34
|
path?: SubPropPath,
|
|
38
|
-
evtName?:
|
|
35
|
+
evtName?: EventName,
|
|
39
36
|
as?: asOptions,
|
|
40
37
|
constVal?: any;
|
|
41
38
|
enhKey?: string;
|
|
@@ -28,8 +28,7 @@ export interface RegExpExt<TStatementGroup = any>{
|
|
|
28
28
|
dssKeys?: [string, string][],
|
|
29
29
|
dssArrayKeys?: [string, string][],
|
|
30
30
|
statementPartParser?: StatementPartParser,
|
|
31
|
-
|
|
32
|
-
// ipeArrayKeys?: [string, string][];
|
|
31
|
+
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
export interface StatementPartParser {
|