@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/state-api/index.js
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import Observer from '@webqit/observer';
|
|
6
|
-
import { _difference } from '@webqit/util/arr/index.js';
|
|
7
|
-
import { _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
|
-
* The State API
|
|
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
|
-
|
|
35
|
-
const _meta = config.call(this, {
|
|
36
|
-
api: {state: 'state', setState: 'setState', clearState: 'clearState',},
|
|
37
|
-
}, _config.params );
|
|
38
|
-
|
|
39
|
-
const getOrCreateState = function(subject, newStateObject = null) {
|
|
40
|
-
if (!_internals(subject, 'oohtml').has('state') || newStateObject) {
|
|
41
|
-
const stateObject = newStateObject || Object.create(null);
|
|
42
|
-
const prevStateObject = _internals(subject, 'oohtml').get('state');
|
|
43
|
-
_internals(subject, 'oohtml').set('state', stateObject);
|
|
44
|
-
if (prevStateObject && Observer.unlink) {
|
|
45
|
-
Observer.unlink(subject, _meta.get('api.state'), prevStateObject);
|
|
46
|
-
}
|
|
47
|
-
if (Observer.link) {
|
|
48
|
-
let event = newStateObject ? {isUpdate: prevStateObject ? true : false, oldValue: prevStateObject} : null;
|
|
49
|
-
Observer.link(subject, _meta.get('api.state'), stateObject, event);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return _internals(subject, 'oohtml').get('state');
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// ----------------------
|
|
56
|
-
// Define the "local" state property on Element.prototype
|
|
57
|
-
// ----------------------
|
|
58
|
-
|
|
59
|
-
if (_meta.get('api.state') in window.Element.prototype) {
|
|
60
|
-
throw new Error('The "Element" class already has a "' + _meta.get('api.state') + '" property!');
|
|
61
|
-
}
|
|
62
|
-
Object.defineProperty(window.Element.prototype, _meta.get('api.state'), {
|
|
63
|
-
get: function() {
|
|
64
|
-
return Observer.proxy(getOrCreateState(this));
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
// ----------------------
|
|
69
|
-
|
|
70
|
-
if (_meta.get('api.setState') in window.Element.prototype) {
|
|
71
|
-
throw new Error('The "Element" class already has a "' + _meta.get('api.setState') + '" property!');
|
|
72
|
-
}
|
|
73
|
-
Object.defineProperty(window.Element.prototype, _meta.get('api.setState'), {
|
|
74
|
-
value: function(stateObject, params = {}) {
|
|
75
|
-
if (!params.update) {
|
|
76
|
-
getOrCreateState(this, stateObject);
|
|
77
|
-
} else {
|
|
78
|
-
var currentStateObject = getOrCreateState(this);
|
|
79
|
-
if (params.update !== 'merge') {
|
|
80
|
-
var outgoingKeys = _difference(Object.keys(currentStateObject), Object.keys(stateObject));
|
|
81
|
-
Observer.deleteProperty(currentStateObject, outgoingKeys);
|
|
82
|
-
}
|
|
83
|
-
Observer.set(currentStateObject, stateObject);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// ----------------------
|
|
89
|
-
|
|
90
|
-
if (_meta.get('api.clearState') in window.Element.prototype) {
|
|
91
|
-
throw new Error('The "Element" class already has a "' + _meta.get('api.clearState') + '" property!');
|
|
92
|
-
}
|
|
93
|
-
Object.defineProperty(window.Element.prototype, _meta.get('api.clearState'), {
|
|
94
|
-
value: function() {
|
|
95
|
-
getOrCreateState(this, {});
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// ----------------------
|
|
100
|
-
// Define the global "state" object
|
|
101
|
-
// ----------------------
|
|
102
|
-
|
|
103
|
-
if (_meta.get('api.state') in document) {
|
|
104
|
-
throw new Error('The "document" object already has a "' + _meta.get('api.state') + '" property!');
|
|
105
|
-
}
|
|
106
|
-
Object.defineProperty(document, _meta.get('api.state'), {
|
|
107
|
-
get: function() {
|
|
108
|
-
return Observer.proxy(getOrCreateState(document));
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// ----------------------
|
|
113
|
-
|
|
114
|
-
if (_meta.get('api.setState') in document) {
|
|
115
|
-
throw new Error('The "document" object already has a "' + _meta.get('api.setState') + '" property!');
|
|
116
|
-
}
|
|
117
|
-
Object.defineProperty(document, _meta.get('api.setState'), {
|
|
118
|
-
value: function(stateObject, params = {}) {
|
|
119
|
-
if (!params.update) {
|
|
120
|
-
getOrCreateState(document, stateObject);
|
|
121
|
-
} else {
|
|
122
|
-
var currentStateObject = getOrCreateState(document);
|
|
123
|
-
if (params.update !== 'merge') {
|
|
124
|
-
var outgoingKeys = _difference(Object.keys(currentStateObject), Object.keys(stateObject));
|
|
125
|
-
Observer.deleteProperty(currentStateObject, outgoingKeys);
|
|
126
|
-
}
|
|
127
|
-
Observer.set(currentStateObject, stateObject);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
// ----------------------
|
|
133
|
-
|
|
134
|
-
if (_meta.get('api.clearState') in document) {
|
|
135
|
-
throw new Error('The "document" object already has a "' + _meta.get('api.clearState') + '" property!');
|
|
136
|
-
}
|
|
137
|
-
Object.defineProperty(document, _meta.get('api.clearState'), {
|
|
138
|
-
value: function() {
|
|
139
|
-
getOrCreateState(document, {});
|
|
140
|
-
}
|
|
141
|
-
});
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import Observer from '@webqit/observer';
|
|
6
|
+
import { _difference } from '@webqit/util/arr/index.js';
|
|
7
|
+
import { _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
|
+
* The State API
|
|
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
|
+
|
|
35
|
+
const _meta = config.call(this, {
|
|
36
|
+
api: {state: 'state', setState: 'setState', clearState: 'clearState',},
|
|
37
|
+
}, _config.params );
|
|
38
|
+
|
|
39
|
+
const getOrCreateState = function(subject, newStateObject = null) {
|
|
40
|
+
if (!_internals(subject, 'oohtml').has('state') || newStateObject) {
|
|
41
|
+
const stateObject = newStateObject || Object.create(null);
|
|
42
|
+
const prevStateObject = _internals(subject, 'oohtml').get('state');
|
|
43
|
+
_internals(subject, 'oohtml').set('state', stateObject);
|
|
44
|
+
if (prevStateObject && Observer.unlink) {
|
|
45
|
+
Observer.unlink(subject, _meta.get('api.state'), prevStateObject);
|
|
46
|
+
}
|
|
47
|
+
if (Observer.link) {
|
|
48
|
+
let event = newStateObject ? {isUpdate: prevStateObject ? true : false, oldValue: prevStateObject} : null;
|
|
49
|
+
Observer.link(subject, _meta.get('api.state'), stateObject, event);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return _internals(subject, 'oohtml').get('state');
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// ----------------------
|
|
56
|
+
// Define the "local" state property on Element.prototype
|
|
57
|
+
// ----------------------
|
|
58
|
+
|
|
59
|
+
if (_meta.get('api.state') in window.Element.prototype) {
|
|
60
|
+
throw new Error('The "Element" class already has a "' + _meta.get('api.state') + '" property!');
|
|
61
|
+
}
|
|
62
|
+
Object.defineProperty(window.Element.prototype, _meta.get('api.state'), {
|
|
63
|
+
get: function() {
|
|
64
|
+
return Observer.proxy(getOrCreateState(this));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// ----------------------
|
|
69
|
+
|
|
70
|
+
if (_meta.get('api.setState') in window.Element.prototype) {
|
|
71
|
+
throw new Error('The "Element" class already has a "' + _meta.get('api.setState') + '" property!');
|
|
72
|
+
}
|
|
73
|
+
Object.defineProperty(window.Element.prototype, _meta.get('api.setState'), {
|
|
74
|
+
value: function(stateObject, params = {}) {
|
|
75
|
+
if (!params.update) {
|
|
76
|
+
getOrCreateState(this, stateObject);
|
|
77
|
+
} else {
|
|
78
|
+
var currentStateObject = getOrCreateState(this);
|
|
79
|
+
if (params.update !== 'merge') {
|
|
80
|
+
var outgoingKeys = _difference(Object.keys(currentStateObject), Object.keys(stateObject));
|
|
81
|
+
Observer.deleteProperty(currentStateObject, outgoingKeys);
|
|
82
|
+
}
|
|
83
|
+
Observer.set(currentStateObject, stateObject);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// ----------------------
|
|
89
|
+
|
|
90
|
+
if (_meta.get('api.clearState') in window.Element.prototype) {
|
|
91
|
+
throw new Error('The "Element" class already has a "' + _meta.get('api.clearState') + '" property!');
|
|
92
|
+
}
|
|
93
|
+
Object.defineProperty(window.Element.prototype, _meta.get('api.clearState'), {
|
|
94
|
+
value: function() {
|
|
95
|
+
getOrCreateState(this, {});
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// ----------------------
|
|
100
|
+
// Define the global "state" object
|
|
101
|
+
// ----------------------
|
|
102
|
+
|
|
103
|
+
if (_meta.get('api.state') in document) {
|
|
104
|
+
throw new Error('The "document" object already has a "' + _meta.get('api.state') + '" property!');
|
|
105
|
+
}
|
|
106
|
+
Object.defineProperty(document, _meta.get('api.state'), {
|
|
107
|
+
get: function() {
|
|
108
|
+
return Observer.proxy(getOrCreateState(document));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// ----------------------
|
|
113
|
+
|
|
114
|
+
if (_meta.get('api.setState') in document) {
|
|
115
|
+
throw new Error('The "document" object already has a "' + _meta.get('api.setState') + '" property!');
|
|
116
|
+
}
|
|
117
|
+
Object.defineProperty(document, _meta.get('api.setState'), {
|
|
118
|
+
value: function(stateObject, params = {}) {
|
|
119
|
+
if (!params.update) {
|
|
120
|
+
getOrCreateState(document, stateObject);
|
|
121
|
+
} else {
|
|
122
|
+
var currentStateObject = getOrCreateState(document);
|
|
123
|
+
if (params.update !== 'merge') {
|
|
124
|
+
var outgoingKeys = _difference(Object.keys(currentStateObject), Object.keys(stateObject));
|
|
125
|
+
Observer.deleteProperty(currentStateObject, outgoingKeys);
|
|
126
|
+
}
|
|
127
|
+
Observer.set(currentStateObject, stateObject);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// ----------------------
|
|
133
|
+
|
|
134
|
+
if (_meta.get('api.clearState') in document) {
|
|
135
|
+
throw new Error('The "document" object already has a "' + _meta.get('api.clearState') + '" property!');
|
|
136
|
+
}
|
|
137
|
+
Object.defineProperty(document, _meta.get('api.clearState'), {
|
|
138
|
+
value: function() {
|
|
139
|
+
getOrCreateState(document, {});
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
142
|
};
|
package/src/subscript/Element.js
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import { SubscriptFunction, SubscriptClass } from '@webqit/subscript';
|
|
6
|
-
import { _internals, _isNumeric, _isFunction } from '@webqit/util/js/index.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* ---------------------------
|
|
10
|
-
* Subscript Element
|
|
11
|
-
* ---------------------------
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export const Element = BaseElement => class extends SubscriptClass( BaseElement ) {
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @subscript Element
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
static get subscriptParams() {
|
|
21
|
-
return { globalsAutoObserve: [ 'document' ] };
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static expose( element, subscriptFunction ) {
|
|
25
|
-
let subscriptInstances = _internals( element, 'oohtml', 'subscript', 'instances' );
|
|
26
|
-
let id = subscriptFunction.name;
|
|
27
|
-
if ( !id ) {
|
|
28
|
-
id = [ ...subscriptInstances.keys() ].filter( k => _isNumeric( k ) ).length;
|
|
29
|
-
}
|
|
30
|
-
subscriptInstances.set( id, subscriptFunction );
|
|
31
|
-
return subscriptFunction;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
static implementMethod( method, element ) {
|
|
36
|
-
let subscriptFunction = super.implementMethod( method, element );
|
|
37
|
-
return this.expose( element, subscriptFunction );
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
static implementScript( script, element ) {
|
|
41
|
-
let source = ( script.textContent || '' ).trim();
|
|
42
|
-
return this.expose( element, SubscriptFunction.call( element, source, { compilerParams: this.compilerParams, runtimeParams: this.runtimeParams } ) );
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @disconnectedCallback()
|
|
47
|
-
*/
|
|
48
|
-
static doConnectedCallback( instance ) {
|
|
49
|
-
if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
|
|
50
|
-
const subscriptInstances = _internals( instance, 'oohtml', 'subscript', 'instances' );
|
|
51
|
-
const signals = ( mutations, evt, namespace = [] ) => {
|
|
52
|
-
subscriptInstances.forEach( api => api.thread( ...mutations.map( mu => namespace.concat( mu.path ) ) ) );
|
|
53
|
-
};
|
|
54
|
-
( this.subscriptParams.globalsAutoObserve || [] ).forEach( identifier => {
|
|
55
|
-
WebQit.Observer.observe( globalThis[ identifier ], mutations => signals( mutations, null, [ identifier ] ), {
|
|
56
|
-
subtree: true, diff: true, tags: [ instance, 'subscript-element', identifier ], unique: true
|
|
57
|
-
} );
|
|
58
|
-
} );
|
|
59
|
-
WebQit.Observer.observe( instance, mutations => signals( mutations, null, [ 'this' ] ), {
|
|
60
|
-
subtree: true, diff: true, tags: [ instance, 'subscript-element', 'this' ], unique: true
|
|
61
|
-
} );
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @disconnectedCallback()
|
|
66
|
-
*/
|
|
67
|
-
static doDisconnectedCallback( instance ) {
|
|
68
|
-
if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
|
|
69
|
-
( this.subscriptParams.globalsAutoObserve || [] ).forEach( identifier => {
|
|
70
|
-
WebQit.Observer.unobserve( globalThis[ identifier ], null, null, {
|
|
71
|
-
subtree: true, tags: [ instance, 'subscript-element', identifier ]
|
|
72
|
-
} );
|
|
73
|
-
} );
|
|
74
|
-
WebQit.Observer.unobserve( instance, null, null, {
|
|
75
|
-
subtree: true, tags: [ instance, 'subscript-element', 'this' ]
|
|
76
|
-
} );
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @connectedCallback()
|
|
81
|
-
*/
|
|
82
|
-
connectedCallback() {
|
|
83
|
-
this.constructor.doConnectedCallback( this );
|
|
84
|
-
if ( super.connectedCallback ) {
|
|
85
|
-
super.connectedCallback();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* @disconnectedCallback()
|
|
91
|
-
*/
|
|
92
|
-
disconnectedCallback() {
|
|
93
|
-
this.constructor.doDisconnectedCallback( this );
|
|
94
|
-
if ( super.disconnectedCallback ) {
|
|
95
|
-
super.disconnectedCallback();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
get subscript() {
|
|
100
|
-
return _internals( this, 'oohtml', 'subscript', 'instances' );
|
|
101
|
-
}
|
|
102
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import { SubscriptFunction, SubscriptClass } from '@webqit/subscript';
|
|
6
|
+
import { _internals, _isNumeric, _isFunction } from '@webqit/util/js/index.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ---------------------------
|
|
10
|
+
* Subscript Element
|
|
11
|
+
* ---------------------------
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export const Element = BaseElement => class extends SubscriptClass( BaseElement ) {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @subscript Element
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
static get subscriptParams() {
|
|
21
|
+
return { globalsAutoObserve: [ 'document' ] };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static expose( element, subscriptFunction ) {
|
|
25
|
+
let subscriptInstances = _internals( element, 'oohtml', 'subscript', 'instances' );
|
|
26
|
+
let id = subscriptFunction.name;
|
|
27
|
+
if ( !id ) {
|
|
28
|
+
id = [ ...subscriptInstances.keys() ].filter( k => _isNumeric( k ) ).length;
|
|
29
|
+
}
|
|
30
|
+
subscriptInstances.set( id, subscriptFunction );
|
|
31
|
+
return subscriptFunction;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
static implementMethod( method, element ) {
|
|
36
|
+
let subscriptFunction = super.implementMethod( method, element );
|
|
37
|
+
return this.expose( element, subscriptFunction );
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static implementScript( script, element ) {
|
|
41
|
+
let source = ( script.textContent || '' ).trim();
|
|
42
|
+
return this.expose( element, SubscriptFunction.call( element, source, { compilerParams: this.compilerParams, runtimeParams: this.runtimeParams } ) );
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @disconnectedCallback()
|
|
47
|
+
*/
|
|
48
|
+
static doConnectedCallback( instance ) {
|
|
49
|
+
if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
|
|
50
|
+
const subscriptInstances = _internals( instance, 'oohtml', 'subscript', 'instances' );
|
|
51
|
+
const signals = ( mutations, evt, namespace = [] ) => {
|
|
52
|
+
subscriptInstances.forEach( api => api.thread( ...mutations.map( mu => namespace.concat( mu.path ) ) ) );
|
|
53
|
+
};
|
|
54
|
+
( this.subscriptParams.globalsAutoObserve || [] ).forEach( identifier => {
|
|
55
|
+
WebQit.Observer.observe( globalThis[ identifier ], mutations => signals( mutations, null, [ identifier ] ), {
|
|
56
|
+
subtree: true, diff: true, tags: [ instance, 'subscript-element', identifier ], unique: true
|
|
57
|
+
} );
|
|
58
|
+
} );
|
|
59
|
+
WebQit.Observer.observe( instance, mutations => signals( mutations, null, [ 'this' ] ), {
|
|
60
|
+
subtree: true, diff: true, tags: [ instance, 'subscript-element', 'this' ], unique: true
|
|
61
|
+
} );
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @disconnectedCallback()
|
|
66
|
+
*/
|
|
67
|
+
static doDisconnectedCallback( instance ) {
|
|
68
|
+
if ( ( typeof WebQit === 'undefined' ) || !WebQit.Observer ) return;
|
|
69
|
+
( this.subscriptParams.globalsAutoObserve || [] ).forEach( identifier => {
|
|
70
|
+
WebQit.Observer.unobserve( globalThis[ identifier ], null, null, {
|
|
71
|
+
subtree: true, tags: [ instance, 'subscript-element', identifier ]
|
|
72
|
+
} );
|
|
73
|
+
} );
|
|
74
|
+
WebQit.Observer.unobserve( instance, null, null, {
|
|
75
|
+
subtree: true, tags: [ instance, 'subscript-element', 'this' ]
|
|
76
|
+
} );
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @connectedCallback()
|
|
81
|
+
*/
|
|
82
|
+
connectedCallback() {
|
|
83
|
+
this.constructor.doConnectedCallback( this );
|
|
84
|
+
if ( super.connectedCallback ) {
|
|
85
|
+
super.connectedCallback();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* @disconnectedCallback()
|
|
91
|
+
*/
|
|
92
|
+
disconnectedCallback() {
|
|
93
|
+
this.constructor.doDisconnectedCallback( this );
|
|
94
|
+
if ( super.disconnectedCallback ) {
|
|
95
|
+
super.disconnectedCallback();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
get subscript() {
|
|
100
|
+
return _internals( this, 'oohtml', 'subscript', 'instances' );
|
|
101
|
+
}
|
|
102
|
+
|
|
103
103
|
}
|
|
@@ -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 );
|
package/src/subscript/index.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import { _internals } from '@webqit/util/js/index.js';
|
|
6
|
-
import domInit from '@webqit/browser-pie/src/dom/index.js';
|
|
7
|
-
import { Element } from './Element.js';
|
|
8
|
-
import { config } from '../util.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @init
|
|
12
|
-
*
|
|
13
|
-
* @param Object config
|
|
14
|
-
*/
|
|
15
|
-
export default function init( _config = {} ) {
|
|
16
|
-
|
|
17
|
-
const WebQit = domInit.call( this );
|
|
18
|
-
if ( _config.onDomReady ) {
|
|
19
|
-
WebQit.DOM.ready( () => {
|
|
20
|
-
init.call( this, { ..._config, onDomReady: false } );
|
|
21
|
-
} );
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const mutations = WebQit.DOM.mutations;
|
|
26
|
-
const _meta = config.call( this, {
|
|
27
|
-
selectors: { script: 'script[type="subscript"]', },
|
|
28
|
-
api: { bind: 'bind', unbind: 'unbind', },
|
|
29
|
-
script: {},
|
|
30
|
-
}, _config.params );
|
|
31
|
-
|
|
32
|
-
const ContextifiableElement = BaseElement => class extends Element( BaseElement ) {
|
|
33
|
-
static get compilerParams() {
|
|
34
|
-
return _config.compilerParams || {};
|
|
35
|
-
}
|
|
36
|
-
static get runtimeParams() {
|
|
37
|
-
return _config.runtimeParams || {};
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const SubscriptElement = ContextifiableElement();
|
|
42
|
-
mutations.onPresent( _meta.get('selectors.script'), scriptElement => {
|
|
43
|
-
|
|
44
|
-
let ownerNode = scriptElement.parentNode;
|
|
45
|
-
if ( !ownerNode ) return;
|
|
46
|
-
let scriptTags = _internals( ownerNode, 'oohtml', 'subscript' ).get( 'script-tags' );
|
|
47
|
-
if ( !scriptTags ) {
|
|
48
|
-
scriptTags = new WeakSet;
|
|
49
|
-
_internals( ownerNode, 'oohtml', 'subscript' ).set( 'script-tags', scriptTags );
|
|
50
|
-
}
|
|
51
|
-
if ( scriptTags.has( scriptElement ) ) return;
|
|
52
|
-
|
|
53
|
-
SubscriptElement.implementScript( scriptElement, ownerNode )();
|
|
54
|
-
SubscriptElement.doConnectedCallback( ownerNode );
|
|
55
|
-
scriptTags.add( scriptElement );
|
|
56
|
-
|
|
57
|
-
let mo = mutations.onRemoved( ownerNode, () => {
|
|
58
|
-
SubscriptElement.doDisconnectedCallback( ownerNode );
|
|
59
|
-
scriptTags.delete( scriptElement );
|
|
60
|
-
mo.disconnect();
|
|
61
|
-
}, { ignoreTransients: true });
|
|
62
|
-
|
|
63
|
-
} );
|
|
64
|
-
|
|
65
|
-
if (!WebQit.OOHTML) {
|
|
66
|
-
WebQit.OOHTML = {};
|
|
67
|
-
}
|
|
68
|
-
WebQit.OOHTML.SubscriptElement = ContextifiableElement;
|
|
69
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import { _internals } from '@webqit/util/js/index.js';
|
|
6
|
+
import domInit from '@webqit/browser-pie/src/dom/index.js';
|
|
7
|
+
import { Element } from './Element.js';
|
|
8
|
+
import { config } from '../util.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @init
|
|
12
|
+
*
|
|
13
|
+
* @param Object config
|
|
14
|
+
*/
|
|
15
|
+
export default function init( _config = {} ) {
|
|
16
|
+
|
|
17
|
+
const WebQit = domInit.call( this );
|
|
18
|
+
if ( _config.onDomReady ) {
|
|
19
|
+
WebQit.DOM.ready( () => {
|
|
20
|
+
init.call( this, { ..._config, onDomReady: false } );
|
|
21
|
+
} );
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const mutations = WebQit.DOM.mutations;
|
|
26
|
+
const _meta = config.call( this, {
|
|
27
|
+
selectors: { script: 'script[type="subscript"]', },
|
|
28
|
+
api: { bind: 'bind', unbind: 'unbind', },
|
|
29
|
+
script: {},
|
|
30
|
+
}, _config.params );
|
|
31
|
+
|
|
32
|
+
const ContextifiableElement = BaseElement => class extends Element( BaseElement ) {
|
|
33
|
+
static get compilerParams() {
|
|
34
|
+
return _config.compilerParams || {};
|
|
35
|
+
}
|
|
36
|
+
static get runtimeParams() {
|
|
37
|
+
return _config.runtimeParams || {};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const SubscriptElement = ContextifiableElement();
|
|
42
|
+
mutations.onPresent( _meta.get('selectors.script'), scriptElement => {
|
|
43
|
+
|
|
44
|
+
let ownerNode = scriptElement.parentNode;
|
|
45
|
+
if ( !ownerNode ) return;
|
|
46
|
+
let scriptTags = _internals( ownerNode, 'oohtml', 'subscript' ).get( 'script-tags' );
|
|
47
|
+
if ( !scriptTags ) {
|
|
48
|
+
scriptTags = new WeakSet;
|
|
49
|
+
_internals( ownerNode, 'oohtml', 'subscript' ).set( 'script-tags', scriptTags );
|
|
50
|
+
}
|
|
51
|
+
if ( scriptTags.has( scriptElement ) ) return;
|
|
52
|
+
|
|
53
|
+
SubscriptElement.implementScript( scriptElement, ownerNode )();
|
|
54
|
+
SubscriptElement.doConnectedCallback( ownerNode );
|
|
55
|
+
scriptTags.add( scriptElement );
|
|
56
|
+
|
|
57
|
+
let mo = mutations.onRemoved( ownerNode, () => {
|
|
58
|
+
SubscriptElement.doDisconnectedCallback( ownerNode );
|
|
59
|
+
scriptTags.delete( scriptElement );
|
|
60
|
+
mo.disconnect();
|
|
61
|
+
}, { ignoreTransients: true });
|
|
62
|
+
|
|
63
|
+
} );
|
|
64
|
+
|
|
65
|
+
if (!WebQit.OOHTML) {
|
|
66
|
+
WebQit.OOHTML = {};
|
|
67
|
+
}
|
|
68
|
+
WebQit.OOHTML.SubscriptElement = ContextifiableElement;
|
|
69
|
+
|
|
70
70
|
}
|