@webqit/oohtml 1.10.3 → 2.0.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/.gitignore +3 -3
- package/LICENSE +20 -20
- package/README.md +399 -396
- package/dist/context-api.js +2 -0
- package/dist/context-api.js.map +7 -0
- package/dist/html-imports.js +1 -2
- package/dist/html-imports.js.map +3 -3
- package/dist/html-modules.js +1 -2
- package/dist/html-modules.js.map +3 -3
- package/dist/main.js +26 -14
- package/dist/main.js.map +3 -3
- package/dist/namespaced-html.js +1 -2
- package/dist/namespaced-html.js.map +3 -3
- package/dist/scoped-js.js +27 -0
- package/dist/scoped-js.js.map +7 -0
- package/dist/state-api.js +1 -2
- package/dist/state-api.js.map +3 -3
- package/package.json +76 -76
- package/src/context-api/HTMLContext.js +158 -0
- package/src/context-api/HTMLContextManager.js +77 -0
- package/src/context-api/_ContextRequestEvent.js +26 -0
- package/src/context-api/index.js +53 -0
- package/src/{namespaced-html/browser-entry.js → context-api/targets.browser.js} +9 -9
- package/src/html-imports/_HTMLImportElement.js +216 -0
- package/src/html-imports/index.js +92 -557
- package/src/{browser-entry.js → html-imports/targets.browser.js} +10 -10
- package/src/html-modules/HTMLExportsManager.js +191 -0
- package/src/html-modules/_HTMLImportsContext.js +114 -0
- package/src/html-modules/index.js +133 -384
- package/src/{html-imports/browser-entry.js → html-modules/targets.browser.js} +9 -9
- package/src/index.js +34 -39
- package/src/namespaced-html/index.js +130 -144
- package/src/namespaced-html/targets.browser.js +10 -0
- package/src/scoped-js/index.js +382 -0
- package/src/scoped-js/targets.browser.js +10 -0
- package/src/state-api/index.js +55 -142
- package/src/state-api/targets.browser.js +10 -0
- package/src/{html-modules/browser-entry.js → targets.browser.js} +10 -10
- package/src/util.js +20 -180
- package/test/imports.test.js +194 -0
- package/test/index.js +119 -0
- package/test/modules.test.js +198 -0
- package/test/namespaced-html.test.js +50 -0
- package/test/scoped-js.js +57 -0
- package/test/state-api.test.js +34 -0
- package/test/test.html +69 -0
- package/dist/subscript.js +0 -15
- package/dist/subscript.js.map +0 -7
- package/src/state-api/browser-entry.js +0 -10
- package/src/subscript/Element.js +0 -103
- package/src/subscript/browser-entry.js +0 -10
- package/src/subscript/index.js +0 -70
- package/test/all.test.js +0 -0
package/package.json
CHANGED
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@webqit/oohtml",
|
|
3
|
-
"title": "CHTML",
|
|
4
|
-
"description": "A suite of new DOM features that brings language support for modern UI development paradigms: a component-based architecture, data binding, and reactivity.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"namespaced-HTML",
|
|
7
|
-
"html-modules",
|
|
8
|
-
"ui-state",
|
|
9
|
-
"html-imports",
|
|
10
|
-
"reflex",
|
|
11
|
-
"subscript",
|
|
12
|
-
"scoped-js",
|
|
13
|
-
"UI",
|
|
14
|
-
"wicg-proposal"
|
|
15
|
-
],
|
|
16
|
-
"homepage": "https://webqit.io/tooling/oohtml",
|
|
17
|
-
"version": "
|
|
18
|
-
"license": "MIT",
|
|
19
|
-
"repository": {
|
|
20
|
-
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/webqit/oohtml.git"
|
|
22
|
-
},
|
|
23
|
-
"bugs": {
|
|
24
|
-
"url": "https://github.com/webqit/oohtml/issues"
|
|
25
|
-
},
|
|
26
|
-
"type": "module",
|
|
27
|
-
"sideEffects": false,
|
|
28
|
-
"browser": {
|
|
29
|
-
"fs": false
|
|
30
|
-
},
|
|
31
|
-
"main": "./src/index.js",
|
|
32
|
-
"scripts": {
|
|
33
|
-
"test": "mocha --extension .test.js --exit",
|
|
34
|
-
"test:coverage": "c8 --reporter=text-lcov npm run test | coveralls",
|
|
35
|
-
"build": "esbuild main=src/browser
|
|
36
|
-
"preversion": "npm run test && npm run build && git add -A dist",
|
|
37
|
-
"postversion": "npm publish",
|
|
38
|
-
"postpublish": "git push && git push --tags"
|
|
39
|
-
},
|
|
40
|
-
"dependencies": {
|
|
41
|
-
"@webqit/
|
|
42
|
-
"@webqit/observer": "^
|
|
43
|
-
"@webqit/subscript": "^2.1.
|
|
44
|
-
"@webqit/util": "^0.8.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"mocha": "^
|
|
52
|
-
"mocha-lcov-reporter": "^1.3.0"
|
|
53
|
-
},
|
|
54
|
-
"author": "Oxford Harrison <oxharris.dev@gmail.com>",
|
|
55
|
-
"maintainers": [
|
|
56
|
-
"Oxford Harrison <oxharris.dev@gmail.com>"
|
|
57
|
-
],
|
|
58
|
-
"contributors": [],
|
|
59
|
-
"funding": {
|
|
60
|
-
"type": "patreon",
|
|
61
|
-
"url": "https://patreon.com/ox_harris"
|
|
62
|
-
},
|
|
63
|
-
"badges": {
|
|
64
|
-
"list": [
|
|
65
|
-
"npmversion",
|
|
66
|
-
"npmdownloads"
|
|
67
|
-
],
|
|
68
|
-
"config": {
|
|
69
|
-
"patreonUsername": "ox_harris",
|
|
70
|
-
"githubUsername": "webqit",
|
|
71
|
-
"githubRepository": "oohtml",
|
|
72
|
-
"githubSlug": "webqit/oohtml",
|
|
73
|
-
"npmPackageName": "@webqit/oohtml"
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@webqit/oohtml",
|
|
3
|
+
"title": "CHTML",
|
|
4
|
+
"description": "A suite of new DOM features that brings language support for modern UI development paradigms: a component-based architecture, data binding, and reactivity.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"namespaced-HTML",
|
|
7
|
+
"html-modules",
|
|
8
|
+
"ui-state",
|
|
9
|
+
"html-imports",
|
|
10
|
+
"reflex",
|
|
11
|
+
"subscript",
|
|
12
|
+
"scoped-js",
|
|
13
|
+
"UI",
|
|
14
|
+
"wicg-proposal"
|
|
15
|
+
],
|
|
16
|
+
"homepage": "https://webqit.io/tooling/oohtml",
|
|
17
|
+
"version": "2.0.0",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/webqit/oohtml.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/webqit/oohtml/issues"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"browser": {
|
|
29
|
+
"fs": false
|
|
30
|
+
},
|
|
31
|
+
"main": "./src/index.js",
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "mocha --extension .test.js --exit",
|
|
34
|
+
"test:coverage": "c8 --reporter=text-lcov npm run test | coveralls",
|
|
35
|
+
"build": "esbuild main=src/targets.browser.js html-modules=src/html-modules/targets.browser.js html-imports=src/html-imports/targets.browser.js namespaced-html=src/namespaced-html/targets.browser.js scoped-js=src/scoped-js/targets.browser.js state-api=src/state-api/targets.browser.js context-api=src/context-api/targets.browser.js --bundle --minify --sourcemap --outdir=dist",
|
|
36
|
+
"preversion": "npm run test && npm run build && git add -A dist",
|
|
37
|
+
"postversion": "npm publish",
|
|
38
|
+
"postpublish": "git push && git push --tags"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@webqit/dom": "^2.0.0",
|
|
42
|
+
"@webqit/observer": "^2.0.0",
|
|
43
|
+
"@webqit/subscript": "^2.1.34",
|
|
44
|
+
"@webqit/util": "^0.8.9"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"chai": "^4.3.4",
|
|
48
|
+
"coveralls": "^3.1.1",
|
|
49
|
+
"esbuild": "^0.14.43",
|
|
50
|
+
"jsdom": "^20.0.0",
|
|
51
|
+
"mocha": "^10.0.0",
|
|
52
|
+
"mocha-lcov-reporter": "^1.3.0"
|
|
53
|
+
},
|
|
54
|
+
"author": "Oxford Harrison <oxharris.dev@gmail.com>",
|
|
55
|
+
"maintainers": [
|
|
56
|
+
"Oxford Harrison <oxharris.dev@gmail.com>"
|
|
57
|
+
],
|
|
58
|
+
"contributors": [],
|
|
59
|
+
"funding": {
|
|
60
|
+
"type": "patreon",
|
|
61
|
+
"url": "https://patreon.com/ox_harris"
|
|
62
|
+
},
|
|
63
|
+
"badges": {
|
|
64
|
+
"list": [
|
|
65
|
+
"npmversion",
|
|
66
|
+
"npmdownloads"
|
|
67
|
+
],
|
|
68
|
+
"config": {
|
|
69
|
+
"patreonUsername": "ox_harris",
|
|
70
|
+
"githubUsername": "webqit",
|
|
71
|
+
"githubRepository": "oohtml",
|
|
72
|
+
"githubSlug": "webqit/oohtml",
|
|
73
|
+
"npmPackageName": "@webqit/oohtml"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import { _compare } from '../util.js';
|
|
6
|
+
import HTMLContextManager from './HTMLContextManager.js';
|
|
7
|
+
|
|
8
|
+
export default class HTMLContext {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @params
|
|
12
|
+
*/
|
|
13
|
+
static get params() {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @attachTo
|
|
19
|
+
*/
|
|
20
|
+
static attachTo( host, Id, multiple = false ) {
|
|
21
|
+
let instance, contextMgr = HTMLContextManager.instance( host );
|
|
22
|
+
if ( !multiple && ( instance = contextMgr.find( cx => this.matchRequest( cx.id, Id, true ) ) ) ) return instance;
|
|
23
|
+
return contextMgr.attach( new this( Id ) );
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @detachFrom
|
|
28
|
+
*/
|
|
29
|
+
static detachFrom( host, Id, multiple = false ) {
|
|
30
|
+
let instance, contextMgr = HTMLContextManager.instance( host );
|
|
31
|
+
for ( instance of contextMgr[ '#' ].contexts ) {
|
|
32
|
+
if ( !this.matchRequest( instance.id, Id, true ) || ( typeof multiple === 'function' && !multiple( instance ) ) ) continue;
|
|
33
|
+
contextMgr.detach( instance );
|
|
34
|
+
if ( typeof multiple !== 'function' && !multiple ) return instance;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @createId
|
|
40
|
+
*/
|
|
41
|
+
static createId( host, fields = {} ) {
|
|
42
|
+
const id = { type: 'HTMLModules', ...fields };
|
|
43
|
+
if ( id.name ) return id;
|
|
44
|
+
if ( host.getAttribute && !( id.name = ( host.getAttribute( this.params.context.attr.contextname ) || '' ).trim() ) ) {
|
|
45
|
+
delete id.name;
|
|
46
|
+
} else if ( !host.ownerDocument ) {
|
|
47
|
+
id.name = 'root';
|
|
48
|
+
}
|
|
49
|
+
return id;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @createRequest
|
|
54
|
+
*/
|
|
55
|
+
static createRequest( fields = {} ) {
|
|
56
|
+
return { ...fields };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @matchesRequest
|
|
61
|
+
*/
|
|
62
|
+
static matchRequest( id, request, strict = false ) {
|
|
63
|
+
if ( strict ) return _compare( id, request, 1, true );
|
|
64
|
+
return request.type === id.type && !request.name || request.name === id.name;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @constructor
|
|
69
|
+
*/
|
|
70
|
+
constructor( id ) {
|
|
71
|
+
Object.defineProperty( this, 'id', { get: () => id } );
|
|
72
|
+
Object.defineProperty( this, 'subscriptions', { value: new Set } );
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @length()
|
|
77
|
+
*/
|
|
78
|
+
get length() {
|
|
79
|
+
this.subscriptions.size;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @handle()
|
|
84
|
+
*/
|
|
85
|
+
handle( event ) {}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @subscribe()
|
|
89
|
+
*/
|
|
90
|
+
subscribe( event ) {
|
|
91
|
+
this.subscriptions.add( event );
|
|
92
|
+
if ( !event.request.signal ) return;
|
|
93
|
+
event.request.signal.addEventListener( 'abort', () => {
|
|
94
|
+
this.unsubscribe( event );
|
|
95
|
+
} );
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @unsubscribe()
|
|
100
|
+
*/
|
|
101
|
+
unsubscribe( event ) {
|
|
102
|
+
this.subscriptions.delete( event );
|
|
103
|
+
event.request.controller?.abort();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @handleEvent()
|
|
108
|
+
*/
|
|
109
|
+
handleEvent( event ) {
|
|
110
|
+
if ( this.disposed || ( event.target === this.host && !event.request?.selfScoped )
|
|
111
|
+
|| !event.request || typeof event.callback !== 'function' || !this.constructor.matchRequest( this.id, event.request ) ) return;
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
if ( event.type === 'contextclaim' ) {
|
|
114
|
+
const claims = new Set;
|
|
115
|
+
this.subscriptions.forEach( subscriptionEvent => {
|
|
116
|
+
if ( !event.target.contains( subscriptionEvent.request.selfScoped ? subscriptionEvent.target : subscriptionEvent.target.parentNode )
|
|
117
|
+
|| !this.constructor.matchRequest( event.request/*provider ID*/, subscriptionEvent.request/*request ID*/ ) ) return;
|
|
118
|
+
this.subscriptions.delete( subscriptionEvent );
|
|
119
|
+
claims.add( subscriptionEvent );
|
|
120
|
+
} );
|
|
121
|
+
event.respondWith( claims );
|
|
122
|
+
} else if ( event.type === 'contextrequest' ) {
|
|
123
|
+
if ( event.request.live ) { this.subscribe( event ); }
|
|
124
|
+
this.handle( event );
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @initialize()
|
|
130
|
+
*/
|
|
131
|
+
initialize( host ) {
|
|
132
|
+
this.host = host;
|
|
133
|
+
this.disposed = false;
|
|
134
|
+
host.addEventListener( 'contextrequest', this );
|
|
135
|
+
host.addEventListener( 'contextclaim', this );
|
|
136
|
+
HTMLContextManager.instance( host ).ask( this.id, claims => claims.forEach( subscriptionEvent => {
|
|
137
|
+
this.subscribe( subscriptionEvent );
|
|
138
|
+
this.handle( subscriptionEvent );
|
|
139
|
+
} ), { type: 'contextclaim' } );
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @dispose()
|
|
145
|
+
*/
|
|
146
|
+
dispose( host ) {
|
|
147
|
+
this.disposed = true;
|
|
148
|
+
host.removeEventListener( 'contextrequest', this );
|
|
149
|
+
host.removeEventListener( 'contextclaim', this );
|
|
150
|
+
this.subscriptions.forEach( subscriptionEvent => {
|
|
151
|
+
this.unsubscribe( subscriptionEvent );
|
|
152
|
+
const { target, request, callback, params } = subscriptionEvent;
|
|
153
|
+
HTMLContextManager.instance( target ).ask( request, callback, params );
|
|
154
|
+
} );
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import _ContextRequestEvent from './_ContextRequestEvent.js';
|
|
6
|
+
import { _ } from '../util.js';
|
|
7
|
+
|
|
8
|
+
export default class HTMLContextManager {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @instance
|
|
12
|
+
*/
|
|
13
|
+
static instance( host ) {
|
|
14
|
+
return _( host ).get( 'contextsmanager::instance' ) || new this( host );;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @constructor
|
|
19
|
+
*/
|
|
20
|
+
constructor( host ) {
|
|
21
|
+
_( host ).get( `contextsmanager::instance` )?.dispose();
|
|
22
|
+
_( host ).set( `contextsmanager::instance`, this );
|
|
23
|
+
const priv = { host, contexts: new Set };
|
|
24
|
+
Object.defineProperty( this, '#', { get: () => priv } );
|
|
25
|
+
const ContextRequestEvent = _ContextRequestEvent.call( host.ownerDocument?.defaultView || host.defaultView );
|
|
26
|
+
Object.defineProperty( this, 'ContextRequestEvent', { get: () => ContextRequestEvent } );
|
|
27
|
+
this[ Symbol.iterator ] = function*() {
|
|
28
|
+
const it = priv.contexts[ Symbol.iterator ]();
|
|
29
|
+
yield it.next().value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @length()
|
|
35
|
+
*/
|
|
36
|
+
get length() {
|
|
37
|
+
this[ '#' ].contexts.size;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @find()
|
|
42
|
+
*/
|
|
43
|
+
find( callback ) {
|
|
44
|
+
return [ ...this[ '#' ].contexts ].find( callback );
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @attach()
|
|
49
|
+
*/
|
|
50
|
+
attach( context ) {
|
|
51
|
+
this[ '#' ].contexts.add( context );
|
|
52
|
+
context.initialize( this[ '#' ].host );
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* @detach()
|
|
57
|
+
*/
|
|
58
|
+
detach( context ) {
|
|
59
|
+
context.dispose( this[ '#' ].host );
|
|
60
|
+
this[ '#' ].contexts.delete( context );
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @ask()
|
|
65
|
+
*/
|
|
66
|
+
ask( request, callback, params = {} ) {
|
|
67
|
+
return this[ '#' ].host.dispatchEvent(
|
|
68
|
+
new this.ContextRequestEvent( request, callback, { bubbles: true, ...params } )
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @dispose()
|
|
74
|
+
*/
|
|
75
|
+
dispose() {}
|
|
76
|
+
|
|
77
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
|
|
2
|
+
export default function() {
|
|
3
|
+
const window = this;
|
|
4
|
+
return class ContextRequestEvent extends window.Event {
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @constructor
|
|
8
|
+
*/
|
|
9
|
+
constructor( request, callback, { type = 'contextrequest', ...params } = {} ) {
|
|
10
|
+
super( type, params );
|
|
11
|
+
Object.defineProperty( this, 'request', { get: () => request } );
|
|
12
|
+
Object.defineProperty( this, 'callback', { get: () => callback } );
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @respondWith
|
|
17
|
+
*/
|
|
18
|
+
respondWith( response, ...rest ) {
|
|
19
|
+
if ( this.request.diff ) {
|
|
20
|
+
if ( 'previousValue' in this && this.previousValue === response ) return;
|
|
21
|
+
this.previousValue = response;
|
|
22
|
+
}
|
|
23
|
+
return this.callback( response, ...rest );
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import wqDom from '@webqit/dom';
|
|
6
|
+
import HTMLContextManager from './HTMLContextManager.js';
|
|
7
|
+
import HTMLContext from './HTMLContext.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Initializes HTML Modules.
|
|
11
|
+
*
|
|
12
|
+
* @param $params Object
|
|
13
|
+
*
|
|
14
|
+
* @return Void
|
|
15
|
+
*/
|
|
16
|
+
export default function init( $params = { }) {
|
|
17
|
+
const window = this, dom = wqDom.call( window );
|
|
18
|
+
// -------
|
|
19
|
+
const params = dom.meta( 'oohtml' ).copyWithDefaults( $params, {
|
|
20
|
+
api: { context: 'context', },
|
|
21
|
+
} );
|
|
22
|
+
// -------
|
|
23
|
+
exposeModulesObjects.call( this, params );
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Exposes HTML Modules with native APIs.
|
|
28
|
+
*
|
|
29
|
+
* @param Object params
|
|
30
|
+
*
|
|
31
|
+
* @return Void
|
|
32
|
+
*/
|
|
33
|
+
function exposeModulesObjects( params ) {
|
|
34
|
+
const window = this;
|
|
35
|
+
// Assertions
|
|
36
|
+
if ( params.api.context in window.document ) { throw new Error( `document already has a "${ params.api.context }" property!` ); }
|
|
37
|
+
if ( params.api.context in window.HTMLElement.prototype ) { throw new Error( `The "HTMLElement" class already has a "${ params.api.context }" property!` ); }
|
|
38
|
+
// Definitions
|
|
39
|
+
Object.defineProperty( window.document, params.api.context, { get: function() {
|
|
40
|
+
return HTMLContextManager.instance( window.document );
|
|
41
|
+
} } );
|
|
42
|
+
Object.defineProperty( window.HTMLElement.prototype, params.api.context, { get: function() {
|
|
43
|
+
return HTMLContextManager.instance( this );
|
|
44
|
+
} } );
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @exports
|
|
49
|
+
*/
|
|
50
|
+
export {
|
|
51
|
+
HTMLContextManager,
|
|
52
|
+
HTMLContext,
|
|
53
|
+
}
|
|
@@ -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 );
|