@webqit/oohtml 1.10.2 → 1.10.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.
- package/.gitignore +3 -3
- package/LICENSE +21 -0
- package/README.md +400 -396
- package/dist/html-imports.js.map +1 -1
- package/dist/html-modules.js.map +1 -1
- package/dist/main.js.map +1 -1
- package/dist/namespaced-html.js.map +1 -1
- package/dist/state-api.js.map +1 -1
- package/dist/subscript.js.map +1 -1
- package/package.json +76 -76
- package/src/browser-entry.js +9 -9
- package/src/html-imports/browser-entry.js +9 -9
- package/src/html-imports/index.js +557 -557
- package/src/html-modules/browser-entry.js +9 -9
- package/src/html-modules/index.js +384 -384
- package/src/index.js +38 -38
- package/src/namespaced-html/browser-entry.js +9 -9
- package/src/namespaced-html/index.js +143 -143
- package/src/state-api/browser-entry.js +9 -9
- package/src/state-api/index.js +141 -141
- package/src/subscript/Element.js +102 -102
- package/src/subscript/browser-entry.js +9 -9
- package/src/subscript/index.js +69 -69
- package/src/util.js +180 -180
package/src/index.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import Observer from '@webqit/observer';
|
|
6
|
-
import domInit from '@webqit/browser-pie/src/dom/index.js';
|
|
7
|
-
import HTMLModules from './html-modules/index.js';
|
|
8
|
-
import HTMLImports from './html-imports/index.js';
|
|
9
|
-
import NamespacedHTML from './namespaced-html/index.js';
|
|
10
|
-
import StateAPI from './state-api/index.js';
|
|
11
|
-
import Subscript from './subscript/index.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @init
|
|
15
|
-
*/
|
|
16
|
-
export default function init(configs = {}) {
|
|
17
|
-
|
|
18
|
-
const WebQit = domInit.call(this);
|
|
19
|
-
if (WebQit.OOHTML) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
// --------------
|
|
23
|
-
WebQit.OOHTML = {};
|
|
24
|
-
WebQit.Observer = Observer;
|
|
25
|
-
// --------------
|
|
26
|
-
HTMLModules.call(this, (configs.HTMLModules || {}));
|
|
27
|
-
HTMLImports.call(this, (configs.HTMLImports || {}));
|
|
28
|
-
NamespacedHTML.call(this, (configs.NamespacedHTML || {}));
|
|
29
|
-
StateAPI.call(this, (configs.StateAPI || {}));
|
|
30
|
-
Subscript.call(this, (configs.Subscript || {}));
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @exports
|
|
36
|
-
*/
|
|
37
|
-
export {
|
|
38
|
-
Observer,
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import Observer from '@webqit/observer';
|
|
6
|
+
import domInit from '@webqit/browser-pie/src/dom/index.js';
|
|
7
|
+
import HTMLModules from './html-modules/index.js';
|
|
8
|
+
import HTMLImports from './html-imports/index.js';
|
|
9
|
+
import NamespacedHTML from './namespaced-html/index.js';
|
|
10
|
+
import StateAPI from './state-api/index.js';
|
|
11
|
+
import Subscript from './subscript/index.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @init
|
|
15
|
+
*/
|
|
16
|
+
export default function init(configs = {}) {
|
|
17
|
+
|
|
18
|
+
const WebQit = domInit.call(this);
|
|
19
|
+
if (WebQit.OOHTML) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
// --------------
|
|
23
|
+
WebQit.OOHTML = {};
|
|
24
|
+
WebQit.Observer = Observer;
|
|
25
|
+
// --------------
|
|
26
|
+
HTMLModules.call(this, (configs.HTMLModules || {}));
|
|
27
|
+
HTMLImports.call(this, (configs.HTMLImports || {}));
|
|
28
|
+
NamespacedHTML.call(this, (configs.NamespacedHTML || {}));
|
|
29
|
+
StateAPI.call(this, (configs.StateAPI || {}));
|
|
30
|
+
Subscript.call(this, (configs.Subscript || {}));
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @exports
|
|
36
|
+
*/
|
|
37
|
+
export {
|
|
38
|
+
Observer,
|
|
39
39
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import init from './index.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @init
|
|
9
|
-
*/
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import init from './index.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @init
|
|
9
|
+
*/
|
|
10
10
|
init.call( window );
|
|
@@ -1,144 +1,144 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import Observer from '@webqit/observer';
|
|
6
|
-
import { _any, _from as _arrFrom } from '@webqit/util/arr/index.js';
|
|
7
|
-
import { _isString, _internals } from '@webqit/util/js/index.js';
|
|
8
|
-
import domInit from '@webqit/browser-pie/src/dom/index.js';
|
|
9
|
-
import { config } from '../util.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* ---------------------------
|
|
13
|
-
* Namespaced HTML
|
|
14
|
-
* ---------------------------
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @init
|
|
19
|
-
*
|
|
20
|
-
* @param Object config
|
|
21
|
-
*/
|
|
22
|
-
export default function init( _config = {} ) {
|
|
23
|
-
|
|
24
|
-
const WebQit = domInit.call( this );
|
|
25
|
-
if ( _config.onDomReady ) {
|
|
26
|
-
WebQit.DOM.ready( () => {
|
|
27
|
-
init.call( this, { ..._config, onDomReady: false } );
|
|
28
|
-
} );
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const window = WebQit.window;
|
|
33
|
-
const document = WebQit.window.document;
|
|
34
|
-
const mutations = WebQit.DOM.mutations;
|
|
35
|
-
|
|
36
|
-
const scopedIdInertContexts = [];
|
|
37
|
-
const _meta = config.call(this, {
|
|
38
|
-
attr: {
|
|
39
|
-
namespace: 'namespace',
|
|
40
|
-
id: 'id',
|
|
41
|
-
},
|
|
42
|
-
api: {
|
|
43
|
-
namespace: 'namespace',
|
|
44
|
-
},
|
|
45
|
-
eagermode: true,
|
|
46
|
-
}, _config.params );
|
|
47
|
-
|
|
48
|
-
const getNamespaceObject = function(subject) {
|
|
49
|
-
if (!_internals(subject, 'oohtml').has('namespace')) {
|
|
50
|
-
const namespaceObject = Object.create(null);
|
|
51
|
-
_internals(subject, 'oohtml').set('namespace', namespaceObject);
|
|
52
|
-
if (Observer.link) {
|
|
53
|
-
Observer.link(subject, _meta.get('api.namespace'), namespaceObject);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return _internals(subject, 'oohtml').get('namespace');
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const getPublicNamespaceObject = function(subject) {
|
|
60
|
-
if (!_internals(subject, 'oohtml').has('publicNamespace')) {
|
|
61
|
-
const namespaceObject = getNamespaceObject(subject);
|
|
62
|
-
_internals(subject, 'oohtml').set('publicNamespace', !_meta.get('eagermode') ? namespaceObject : new Proxy(namespaceObject, {
|
|
63
|
-
get(target, name) {
|
|
64
|
-
if (_isString(name) && !namespaceObject[name]) {
|
|
65
|
-
var node = _arrFrom(subject.querySelectorAll('[' + window.CSS.escape(_meta.get('attr.id')) + '="' + name + '"]')).filter(node => {
|
|
66
|
-
var ownerRoot = node.parentNode.closest('[' + window.CSS.escape(_meta.get('attr.namespace')) + ']');
|
|
67
|
-
if (subject === document) {
|
|
68
|
-
// Only IDs without a scope actually belong to the document scope
|
|
69
|
-
return !ownerRoot;
|
|
70
|
-
}
|
|
71
|
-
return ownerRoot === subject;
|
|
72
|
-
})[0];
|
|
73
|
-
if (node) {
|
|
74
|
-
Observer.set(namespaceObject, name, node);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return namespaceObject[name];
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
return _internals(subject, 'oohtml').get('publicNamespace');
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// ----------------------
|
|
85
|
-
// Define the local "namespace" object
|
|
86
|
-
// ----------------------
|
|
87
|
-
|
|
88
|
-
if (_meta.get('api.namespace') in window.Element.prototype) {
|
|
89
|
-
throw new Error('The "Element" class already has a "' + _meta.get('api.namespace') + '" property!');
|
|
90
|
-
}
|
|
91
|
-
Object.defineProperty(window.Element.prototype, _meta.get('api.namespace'), {
|
|
92
|
-
get: function() {
|
|
93
|
-
return getPublicNamespaceObject(this);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// ----------------------
|
|
98
|
-
// Define the global "namespace" object
|
|
99
|
-
// ----------------------
|
|
100
|
-
|
|
101
|
-
if (_meta.get('api.namespace') in document) {
|
|
102
|
-
throw new Error('The "document" object already has a "' + _meta.get('api.namespace') + '" property!');
|
|
103
|
-
}
|
|
104
|
-
Object.defineProperty(document, _meta.get('api.namespace'), {
|
|
105
|
-
get: function() {
|
|
106
|
-
return getPublicNamespaceObject(document);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// ----------------------
|
|
111
|
-
// Capture scoped elements
|
|
112
|
-
// ----------------------
|
|
113
|
-
|
|
114
|
-
mutations.onPresent('[' + window.CSS.escape(_meta.get('attr.id')) + ']', el => {
|
|
115
|
-
var elOohtmlObj = _internals(el, 'oohtml');
|
|
116
|
-
if (elOohtmlObj.get('idAlreadyBeingWatched') || _any(scopedIdInertContexts, inertContext => el.closest(inertContext))) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
var scopedId = el.getAttribute(_meta.get('attr.id')),
|
|
120
|
-
ownerRoot = el.parentNode.closest('[' + window.CSS.escape(_meta.get('attr.namespace')) + ']');
|
|
121
|
-
if (!ownerRoot) {
|
|
122
|
-
ownerRoot = document;
|
|
123
|
-
}
|
|
124
|
-
var namespaceObject = getNamespaceObject(ownerRoot);
|
|
125
|
-
if (namespaceObject[scopedId] !== el) {
|
|
126
|
-
Observer.set(namespaceObject, scopedId, el);
|
|
127
|
-
}
|
|
128
|
-
// new permanent watch
|
|
129
|
-
elOohtmlObj.set('idAlreadyBeingWatched', true);
|
|
130
|
-
mutations.onPresenceChange(el, (els, presence) => {
|
|
131
|
-
if (presence) {
|
|
132
|
-
// ONLY if I am not currently the one in place
|
|
133
|
-
if (namespaceObject[scopedId] !== el) {
|
|
134
|
-
Observer.set(namespaceObject, scopedId, el);
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
// ONLY if I am still the one in place
|
|
138
|
-
if (namespaceObject[scopedId] === el) {
|
|
139
|
-
Observer.deleteProperty(namespaceObject, scopedId);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
});
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import Observer from '@webqit/observer';
|
|
6
|
+
import { _any, _from as _arrFrom } from '@webqit/util/arr/index.js';
|
|
7
|
+
import { _isString, _internals } from '@webqit/util/js/index.js';
|
|
8
|
+
import domInit from '@webqit/browser-pie/src/dom/index.js';
|
|
9
|
+
import { config } from '../util.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* ---------------------------
|
|
13
|
+
* Namespaced HTML
|
|
14
|
+
* ---------------------------
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @init
|
|
19
|
+
*
|
|
20
|
+
* @param Object config
|
|
21
|
+
*/
|
|
22
|
+
export default function init( _config = {} ) {
|
|
23
|
+
|
|
24
|
+
const WebQit = domInit.call( this );
|
|
25
|
+
if ( _config.onDomReady ) {
|
|
26
|
+
WebQit.DOM.ready( () => {
|
|
27
|
+
init.call( this, { ..._config, onDomReady: false } );
|
|
28
|
+
} );
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const window = WebQit.window;
|
|
33
|
+
const document = WebQit.window.document;
|
|
34
|
+
const mutations = WebQit.DOM.mutations;
|
|
35
|
+
|
|
36
|
+
const scopedIdInertContexts = [];
|
|
37
|
+
const _meta = config.call(this, {
|
|
38
|
+
attr: {
|
|
39
|
+
namespace: 'namespace',
|
|
40
|
+
id: 'id',
|
|
41
|
+
},
|
|
42
|
+
api: {
|
|
43
|
+
namespace: 'namespace',
|
|
44
|
+
},
|
|
45
|
+
eagermode: true,
|
|
46
|
+
}, _config.params );
|
|
47
|
+
|
|
48
|
+
const getNamespaceObject = function(subject) {
|
|
49
|
+
if (!_internals(subject, 'oohtml').has('namespace')) {
|
|
50
|
+
const namespaceObject = Object.create(null);
|
|
51
|
+
_internals(subject, 'oohtml').set('namespace', namespaceObject);
|
|
52
|
+
if (Observer.link) {
|
|
53
|
+
Observer.link(subject, _meta.get('api.namespace'), namespaceObject);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return _internals(subject, 'oohtml').get('namespace');
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const getPublicNamespaceObject = function(subject) {
|
|
60
|
+
if (!_internals(subject, 'oohtml').has('publicNamespace')) {
|
|
61
|
+
const namespaceObject = getNamespaceObject(subject);
|
|
62
|
+
_internals(subject, 'oohtml').set('publicNamespace', !_meta.get('eagermode') ? namespaceObject : new Proxy(namespaceObject, {
|
|
63
|
+
get(target, name) {
|
|
64
|
+
if (_isString(name) && !namespaceObject[name]) {
|
|
65
|
+
var node = _arrFrom(subject.querySelectorAll('[' + window.CSS.escape(_meta.get('attr.id')) + '="' + name + '"]')).filter(node => {
|
|
66
|
+
var ownerRoot = node.parentNode.closest('[' + window.CSS.escape(_meta.get('attr.namespace')) + ']');
|
|
67
|
+
if (subject === document) {
|
|
68
|
+
// Only IDs without a scope actually belong to the document scope
|
|
69
|
+
return !ownerRoot;
|
|
70
|
+
}
|
|
71
|
+
return ownerRoot === subject;
|
|
72
|
+
})[0];
|
|
73
|
+
if (node) {
|
|
74
|
+
Observer.set(namespaceObject, name, node);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return namespaceObject[name];
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
return _internals(subject, 'oohtml').get('publicNamespace');
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// ----------------------
|
|
85
|
+
// Define the local "namespace" object
|
|
86
|
+
// ----------------------
|
|
87
|
+
|
|
88
|
+
if (_meta.get('api.namespace') in window.Element.prototype) {
|
|
89
|
+
throw new Error('The "Element" class already has a "' + _meta.get('api.namespace') + '" property!');
|
|
90
|
+
}
|
|
91
|
+
Object.defineProperty(window.Element.prototype, _meta.get('api.namespace'), {
|
|
92
|
+
get: function() {
|
|
93
|
+
return getPublicNamespaceObject(this);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
// ----------------------
|
|
98
|
+
// Define the global "namespace" object
|
|
99
|
+
// ----------------------
|
|
100
|
+
|
|
101
|
+
if (_meta.get('api.namespace') in document) {
|
|
102
|
+
throw new Error('The "document" object already has a "' + _meta.get('api.namespace') + '" property!');
|
|
103
|
+
}
|
|
104
|
+
Object.defineProperty(document, _meta.get('api.namespace'), {
|
|
105
|
+
get: function() {
|
|
106
|
+
return getPublicNamespaceObject(document);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// ----------------------
|
|
111
|
+
// Capture scoped elements
|
|
112
|
+
// ----------------------
|
|
113
|
+
|
|
114
|
+
mutations.onPresent('[' + window.CSS.escape(_meta.get('attr.id')) + ']', el => {
|
|
115
|
+
var elOohtmlObj = _internals(el, 'oohtml');
|
|
116
|
+
if (elOohtmlObj.get('idAlreadyBeingWatched') || _any(scopedIdInertContexts, inertContext => el.closest(inertContext))) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
var scopedId = el.getAttribute(_meta.get('attr.id')),
|
|
120
|
+
ownerRoot = el.parentNode.closest('[' + window.CSS.escape(_meta.get('attr.namespace')) + ']');
|
|
121
|
+
if (!ownerRoot) {
|
|
122
|
+
ownerRoot = document;
|
|
123
|
+
}
|
|
124
|
+
var namespaceObject = getNamespaceObject(ownerRoot);
|
|
125
|
+
if (namespaceObject[scopedId] !== el) {
|
|
126
|
+
Observer.set(namespaceObject, scopedId, el);
|
|
127
|
+
}
|
|
128
|
+
// new permanent watch
|
|
129
|
+
elOohtmlObj.set('idAlreadyBeingWatched', true);
|
|
130
|
+
mutations.onPresenceChange(el, (els, presence) => {
|
|
131
|
+
if (presence) {
|
|
132
|
+
// ONLY if I am not currently the one in place
|
|
133
|
+
if (namespaceObject[scopedId] !== el) {
|
|
134
|
+
Observer.set(namespaceObject, scopedId, el);
|
|
135
|
+
}
|
|
136
|
+
} else {
|
|
137
|
+
// ONLY if I am still the one in place
|
|
138
|
+
if (namespaceObject[scopedId] === el) {
|
|
139
|
+
Observer.deleteProperty(namespaceObject, scopedId);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
144
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import init from './index.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @init
|
|
9
|
-
*/
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import init from './index.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @init
|
|
9
|
+
*/
|
|
10
10
|
init.call( window );
|