@webqit/oohtml 2.1.34 → 2.1.36

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.
Files changed (52) hide show
  1. package/.gitignore +3 -3
  2. package/LICENSE +20 -20
  3. package/README.md +733 -67
  4. package/dist/bindings-api.js +1 -1
  5. package/dist/bindings-api.js.map +3 -3
  6. package/dist/context-api.js +1 -1
  7. package/dist/context-api.js.map +3 -3
  8. package/dist/html-imports.js +1 -1
  9. package/dist/html-imports.js.map +3 -3
  10. package/dist/main.js +12 -12
  11. package/dist/main.js.map +3 -3
  12. package/dist/namespace-api.js +1 -1
  13. package/dist/namespace-api.js.map +3 -3
  14. package/dist/scoped-css.js +2 -2
  15. package/dist/scoped-css.js.map +3 -3
  16. package/dist/scoped-js.js +7 -7
  17. package/dist/scoped-js.js.map +3 -3
  18. package/package.json +76 -76
  19. package/src/bindings-api/index.js +83 -83
  20. package/src/bindings-api/targets.browser.js +10 -10
  21. package/src/context-api/HTMLContext.js +76 -157
  22. package/src/context-api/HTMLContextProvider.js +158 -0
  23. package/src/context-api/_ContextRequestEvent.js +25 -25
  24. package/src/context-api/index.js +51 -51
  25. package/src/context-api/targets.browser.js +9 -9
  26. package/src/{html-modules/HTMLExportsManager.js → html-imports/_HTMLExportsManager.js} +185 -199
  27. package/src/html-imports/_HTMLImportElement.js +211 -213
  28. package/src/{html-modules/_HTMLImportsContext.js → html-imports/_HTMLImportsProvider.js} +122 -114
  29. package/src/html-imports/index.js +197 -88
  30. package/src/html-imports/targets.browser.js +9 -9
  31. package/src/index.js +30 -32
  32. package/src/namespace-api/index.js +144 -144
  33. package/src/namespace-api/targets.browser.js +10 -10
  34. package/src/scoped-css/index.js +45 -45
  35. package/src/scoped-css/targets.browser.js +10 -10
  36. package/src/scoped-js/Compiler.js +297 -297
  37. package/src/scoped-js/index.js +112 -112
  38. package/src/scoped-js/targets.browser.js +10 -10
  39. package/src/targets.browser.js +9 -9
  40. package/src/util.js +34 -34
  41. package/test/bindings-api.test.js +42 -42
  42. package/test/imports.test.js +221 -221
  43. package/test/index.js +50 -50
  44. package/test/modules.test.js +200 -200
  45. package/test/namespace-api.test.js +51 -51
  46. package/test/scoped-css.test.js +31 -31
  47. package/test/scoped-js.test.js +29 -29
  48. package/dist/html-modules.js +0 -2
  49. package/dist/html-modules.js.map +0 -7
  50. package/src/context-api/HTMLContextManager.js +0 -77
  51. package/src/html-modules/index.js +0 -131
  52. package/src/html-modules/targets.browser.js +0 -10
@@ -1,200 +1,200 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { expect } from 'chai';
6
- import { createDocument, mockRemoteFetch, delay } from './index.js';
7
- const getQueryPath = str => str.split( '/' ).join( '/modules/' ).split( '/' );
8
-
9
- describe(`HTML Modules`, function() {
10
-
11
- describe( `APIs...`, function() {
12
-
13
- it ( `The document object and <template> elements should expose a "modules" property...`, async function() {
14
-
15
- const head = `
16
- <template exportid="temp0">
17
- <p>Hello world Export</p>
18
- <p>Hellort</p>
19
- </template>`;
20
- const body = `
21
- <template exportid="temp1" scoped>
22
- <p>Hello world Export</p>
23
- <p>Hellort</p>
24
- </template>`;
25
- const { document } = createDocument( head, body );
26
- await delay( 200 );
27
- // -------
28
- expect( document ).to.have.property( 'modules' );
29
- expect( document.modules[ 'temp0' ] ).to.have.property( 'modules' );
30
- expect( document.modules[ 'temp0' ].exportid ).to.eq( 'temp0' );
31
- // -------
32
- expect( document.body ).to.have.property( 'modules' );
33
- expect( document.body.modules[ 'temp1' ] ).to.have.property( 'modules' );
34
- expect( document.body.modules[ 'temp1' ].exportid ).to.eq( 'temp1' );
35
- } );
36
-
37
- it ( `The document object and <template> elements should expose a "modules" property...`, async function() {
38
-
39
- const body = '', head = `
40
- <template exportid="temp0">
41
- <p>Hello world Export</p>
42
- <p>Hellort</p>
43
- <template exportid="temp1"></template>
44
- <template exportid="temp2" inherits="temp1 temp3">
45
- <p>Hello world Export</p>
46
- <p>Hellort</p>
47
- </template>
48
- </template>`;
49
- const { document, window } = createDocument( head, body );
50
- await delay( 20 );
51
- const { webqit: { Observer } } = window;
52
- // -------
53
- const temp0 = Observer.deep( document.modules, getQueryPath( 'temp0' ), Observer.get );
54
- expect( temp0 ).to.have.property( 'modules' );
55
- expect( temp0.modules[ '#default' ] ).to.have.length( 2 );
56
- const temp2 = Observer.deep( document.modules, getQueryPath( 'temp0/temp2' ), Observer.get );
57
- expect( temp2 ).to.have.property( 'modules' );
58
- // -------
59
- const temp1Inherited = Observer.deep( document.modules, getQueryPath( 'temp0/temp2/temp1' ), Observer.get );
60
- expect( temp1Inherited ).to.have.property( 'modules' );
61
- // -------
62
- const temp3Observed = [];
63
- Observer.deep( document.modules, getQueryPath( 'temp0/temp2/temp3' ), Observer.observe, record => {
64
- temp3Observed.push( record.value );
65
- } );
66
- // -------
67
- const temp3 = document.createElement( 'template' );
68
- temp3.setAttribute( 'exportid', 'temp3' );
69
- temp0.content.appendChild( temp3 );
70
- // -------
71
- expect( temp3Observed ).to.be.an( 'array' ).with.length( 1 );
72
- expect( temp3Observed[ 0 ] ).to.have.property( 'modules' );
73
- // -------
74
- const temp3Inherited = Observer.deep( document.modules, getQueryPath( 'temp0/temp2/temp3' ), Observer.get );
75
- expect( temp3Inherited ).to.have.property( 'modules' );
76
- // -------
77
- } );
78
-
79
- } );
80
-
81
- describe( `Remote...`, function() {
82
- this.timeout( 10000 );
83
-
84
- it( `Add remote lazy module, with a nested remote lazy module, then resolve.`, async function() {
85
-
86
- const head = ``, body = ``;
87
- const { document, window } = createDocument( head, body, window => {
88
- // Define remote responses
89
- const temp0 = `
90
- <template exportid="temp1" src="/temp1.html" loading="lazy"></template>`;
91
- const temp1 = `
92
- <template exportid="temp2" src="/temp2.html"></template>`;
93
- const temp2 = `
94
- <template exportid="temp3"></template>
95
- <p>Hello world Export</p>
96
- <p>Hellort</p>`;
97
- const timeout = 1000;
98
- mockRemoteFetch( window, { '/temp0.html': temp0, '/temp1.html': temp1, '/temp2.html': temp2 }, timeout );
99
- } );
100
- await delay( 20 );
101
- const { webqit: { Observer } } = window;
102
- // -------
103
- // Add a remote module
104
- const templateEl = document.createElement( 'template' );
105
- templateEl.setAttribute( 'exportid', 'temp0' );
106
- templateEl.setAttribute( 'loading', 'lazy' );
107
- templateEl.setAttribute( 'src', '/temp0.html' );
108
- document.head.appendChild( templateEl );
109
- // -------
110
- // Add the import element to with a view to waiting for the remote module
111
- const temp0 = Observer.deep( document.modules, getQueryPath( 'temp0' ), Observer.get );
112
- expect( temp0 ).to.have.property( 'modules' );
113
- await delay( 2100 );
114
- // temp1 shouldn't have been automatically loaded still
115
- const hasTemp1 = Observer.deep( document.modules, getQueryPath( 'temp0/temp1' ), Observer.has );
116
- expect( hasTemp1 ).to.be.false;
117
- // Try access temp1 to trigger loading and await
118
- const _temp1 = await Observer.deep( document.modules, getQueryPath( 'temp0/temp1' ), Observer.get );
119
- expect( _temp1 ).to.have.property( 'modules' );
120
- // -------
121
- // Receive updates
122
- const temp3Observed = [];
123
- Observer.deep( document.modules, getQueryPath( 'temp0/temp1/temp2/temp3' ), Observer.observe, ( record, lifecycle ) => {
124
- temp3Observed.push( record.value );
125
- } );
126
- await delay( 2100 );
127
- // -------
128
- // temp2 should be loaded by now
129
- expect( temp3Observed ).to.be.an( 'array' ).with.length( 1 );
130
- expect( temp3Observed[ 0 ] ).to.have.property( 'modules' );
131
- expect( temp3Observed[ 0 ].getAttribute( 'exportid' ) ).to.eq( 'temp3' );
132
- } );
133
- } );
134
-
135
- describe( `Context...`, function() {
136
- this.timeout( 10000 );
137
-
138
- it( `Use the context API to fire a scoped-request that is imitially resolved from the document and then from a scoped context.`, async function() {
139
-
140
- const head = `
141
- <template exportid="temp0">
142
- <template exportid="temp-head1">
143
- <p>Hello world Export</p>
144
- <p>Hellort</p>
145
- </template>
146
- </template>`;
147
- const body = `
148
- <div></div>`;
149
- const { document, window } = createDocument( head, body );
150
- await delay( 20 );
151
-
152
- // -------
153
- const addScopedModules = () => {
154
- const templateEl = document.createElement( 'template' );
155
- templateEl.setAttribute( 'exportid', 'temp0' );
156
- templateEl.toggleAttribute( 'scoped', true );
157
- const scoped = document.body.appendChild( templateEl );
158
- document.body.setAttribute( 'importscontext', '/' );
159
- return scoped;
160
- };
161
- // -------
162
- const contextRequest = ( el, params, callback ) => {
163
- const request = { type: 'HTMLModules', live: true, ...params };
164
- const event = new document.context.ContextRequestEvent( request, callback, {
165
- bubbles: true,
166
- } );
167
- return el.dispatchEvent( event );
168
- };
169
- // -------
170
- await 'For some reason, the <template> element in the head needs to show up in the document modulesObj';
171
- const modulesObjs = [], div = document.querySelector( 'div' );
172
- // -------
173
- contextRequest( div, { detail: '/temp0', diff: false }, response => {
174
- modulesObjs.push( response );
175
- } );
176
- expect( modulesObjs ).to.have.length( 1 );
177
- expect( modulesObjs[ 0 ] ).to.have.property( 'scoped', false );
178
- // -------
179
- const scoped = addScopedModules();
180
- expect( modulesObjs ).to.have.length( 3 );
181
- expect( modulesObjs[ 1 ] ).to.have.property( 'scoped', true );
182
- expect( modulesObjs[ 2 ] ).to.have.property( 'scoped', true );
183
- // -------
184
- scoped.remove();
185
- expect( modulesObjs ).to.have.length( 4 );
186
- expect( modulesObjs[ 3 ] ).to.have.property( 'scoped', false );
187
- // -------
188
- document.body.appendChild( scoped );
189
- expect( modulesObjs ).to.have.length( 5 );
190
- expect( modulesObjs[ 4 ] ).to.have.property( 'scoped', true );
191
- // -------
192
- const unscoped = document.modules.temp0;
193
- unscoped.remove();
194
- document.head.appendChild( unscoped );
195
- document.body.remove();
196
- expect( modulesObjs ).to.have.length( 5 );
197
- } );
198
- } );
199
-
200
- } );
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import { expect } from 'chai';
6
+ import { createDocument, mockRemoteFetch, delay } from './index.js';
7
+ const getQueryPath = str => str.split( '/' ).join( '/modules/' ).split( '/' );
8
+
9
+ describe(`HTML Modules`, function() {
10
+
11
+ describe( `APIs...`, function() {
12
+
13
+ it ( `The document object and <template> elements should expose a "modules" property...`, async function() {
14
+
15
+ const head = `
16
+ <template exportid="temp0">
17
+ <p>Hello world Export</p>
18
+ <p>Hellort</p>
19
+ </template>`;
20
+ const body = `
21
+ <template exportid="temp1" scoped>
22
+ <p>Hello world Export</p>
23
+ <p>Hellort</p>
24
+ </template>`;
25
+ const { document } = createDocument( head, body );
26
+ await delay( 200 );
27
+ // -------
28
+ expect( document ).to.have.property( 'modules' );
29
+ expect( document.modules[ 'temp0' ] ).to.have.property( 'modules' );
30
+ expect( document.modules[ 'temp0' ].exportid ).to.eq( 'temp0' );
31
+ // -------
32
+ expect( document.body ).to.have.property( 'modules' );
33
+ expect( document.body.modules[ 'temp1' ] ).to.have.property( 'modules' );
34
+ expect( document.body.modules[ 'temp1' ].exportid ).to.eq( 'temp1' );
35
+ } );
36
+
37
+ it ( `The document object and <template> elements should expose a "modules" property...`, async function() {
38
+
39
+ const body = '', head = `
40
+ <template exportid="temp0">
41
+ <p>Hello world Export</p>
42
+ <p>Hellort</p>
43
+ <template exportid="temp1"></template>
44
+ <template exportid="temp2" inherits="temp1 temp3">
45
+ <p>Hello world Export</p>
46
+ <p>Hellort</p>
47
+ </template>
48
+ </template>`;
49
+ const { document, window } = createDocument( head, body );
50
+ await delay( 20 );
51
+ const { webqit: { Observer } } = window;
52
+ // -------
53
+ const temp0 = Observer.deep( document.modules, getQueryPath( 'temp0' ), Observer.get );
54
+ expect( temp0 ).to.have.property( 'modules' );
55
+ expect( temp0.modules[ '#default' ] ).to.have.length( 2 );
56
+ const temp2 = Observer.deep( document.modules, getQueryPath( 'temp0/temp2' ), Observer.get );
57
+ expect( temp2 ).to.have.property( 'modules' );
58
+ // -------
59
+ const temp1Inherited = Observer.deep( document.modules, getQueryPath( 'temp0/temp2/temp1' ), Observer.get );
60
+ expect( temp1Inherited ).to.have.property( 'modules' );
61
+ // -------
62
+ const temp3Observed = [];
63
+ Observer.deep( document.modules, getQueryPath( 'temp0/temp2/temp3' ), Observer.observe, record => {
64
+ temp3Observed.push( record.value );
65
+ } );
66
+ // -------
67
+ const temp3 = document.createElement( 'template' );
68
+ temp3.setAttribute( 'exportid', 'temp3' );
69
+ temp0.content.appendChild( temp3 );
70
+ // -------
71
+ expect( temp3Observed ).to.be.an( 'array' ).with.length( 1 );
72
+ expect( temp3Observed[ 0 ] ).to.have.property( 'modules' );
73
+ // -------
74
+ const temp3Inherited = Observer.deep( document.modules, getQueryPath( 'temp0/temp2/temp3' ), Observer.get );
75
+ expect( temp3Inherited ).to.have.property( 'modules' );
76
+ // -------
77
+ } );
78
+
79
+ } );
80
+
81
+ describe( `Remote...`, function() {
82
+ this.timeout( 10000 );
83
+
84
+ it( `Add remote lazy module, with a nested remote lazy module, then resolve.`, async function() {
85
+
86
+ const head = ``, body = ``;
87
+ const { document, window } = createDocument( head, body, window => {
88
+ // Define remote responses
89
+ const temp0 = `
90
+ <template exportid="temp1" src="/temp1.html" loading="lazy"></template>`;
91
+ const temp1 = `
92
+ <template exportid="temp2" src="/temp2.html"></template>`;
93
+ const temp2 = `
94
+ <template exportid="temp3"></template>
95
+ <p>Hello world Export</p>
96
+ <p>Hellort</p>`;
97
+ const timeout = 1000;
98
+ mockRemoteFetch( window, { '/temp0.html': temp0, '/temp1.html': temp1, '/temp2.html': temp2 }, timeout );
99
+ } );
100
+ await delay( 20 );
101
+ const { webqit: { Observer } } = window;
102
+ // -------
103
+ // Add a remote module
104
+ const templateEl = document.createElement( 'template' );
105
+ templateEl.setAttribute( 'exportid', 'temp0' );
106
+ templateEl.setAttribute( 'loading', 'lazy' );
107
+ templateEl.setAttribute( 'src', '/temp0.html' );
108
+ document.head.appendChild( templateEl );
109
+ // -------
110
+ // Add the import element to with a view to waiting for the remote module
111
+ const temp0 = Observer.deep( document.modules, getQueryPath( 'temp0' ), Observer.get );
112
+ expect( temp0 ).to.have.property( 'modules' );
113
+ await delay( 2100 );
114
+ // temp1 shouldn't have been automatically loaded still
115
+ const hasTemp1 = Observer.deep( document.modules, getQueryPath( 'temp0/temp1' ), Observer.has );
116
+ expect( hasTemp1 ).to.be.false;
117
+ // Try access temp1 to trigger loading and await
118
+ const _temp1 = await Observer.deep( document.modules, getQueryPath( 'temp0/temp1' ), Observer.get );
119
+ expect( _temp1 ).to.have.property( 'modules' );
120
+ // -------
121
+ // Receive updates
122
+ const temp3Observed = [];
123
+ Observer.deep( document.modules, getQueryPath( 'temp0/temp1/temp2/temp3' ), Observer.observe, ( record, lifecycle ) => {
124
+ temp3Observed.push( record.value );
125
+ } );
126
+ await delay( 2100 );
127
+ // -------
128
+ // temp2 should be loaded by now
129
+ expect( temp3Observed ).to.be.an( 'array' ).with.length( 1 );
130
+ expect( temp3Observed[ 0 ] ).to.have.property( 'modules' );
131
+ expect( temp3Observed[ 0 ].getAttribute( 'exportid' ) ).to.eq( 'temp3' );
132
+ } );
133
+ } );
134
+
135
+ describe( `Context...`, function() {
136
+ this.timeout( 10000 );
137
+
138
+ it( `Use the context API to fire a scoped-request that is imitially resolved from the document and then from a scoped context.`, async function() {
139
+
140
+ const head = `
141
+ <template exportid="temp0">
142
+ <template exportid="temp-head1">
143
+ <p>Hello world Export</p>
144
+ <p>Hellort</p>
145
+ </template>
146
+ </template>`;
147
+ const body = `
148
+ <div></div>`;
149
+ const { document, window } = createDocument( head, body );
150
+ await delay( 20 );
151
+
152
+ // -------
153
+ const addScopedModules = () => {
154
+ const templateEl = document.createElement( 'template' );
155
+ templateEl.setAttribute( 'exportid', 'temp0' );
156
+ templateEl.toggleAttribute( 'scoped', true );
157
+ const scoped = document.body.appendChild( templateEl );
158
+ document.body.setAttribute( 'importscontext', '/' );
159
+ return scoped;
160
+ };
161
+ // -------
162
+ const contextRequest = ( el, params, callback ) => {
163
+ const request = { type: 'HTMLModules', live: true, ...params };
164
+ const event = new document.context.ContextRequestEvent( request, callback, {
165
+ bubbles: true,
166
+ } );
167
+ return el.dispatchEvent( event );
168
+ };
169
+ // -------
170
+ await 'For some reason, the <template> element in the head needs to show up in the document modulesObj';
171
+ const modulesObjs = [], div = document.querySelector( 'div' );
172
+ // -------
173
+ contextRequest( div, { detail: '/temp0', diff: false }, response => {
174
+ modulesObjs.push( response );
175
+ } );
176
+ expect( modulesObjs ).to.have.length( 1 );
177
+ expect( modulesObjs[ 0 ] ).to.have.property( 'scoped', false );
178
+ // -------
179
+ const scoped = addScopedModules();
180
+ expect( modulesObjs ).to.have.length( 3 );
181
+ expect( modulesObjs[ 1 ] ).to.have.property( 'scoped', true );
182
+ expect( modulesObjs[ 2 ] ).to.have.property( 'scoped', true );
183
+ // -------
184
+ scoped.remove();
185
+ expect( modulesObjs ).to.have.length( 4 );
186
+ expect( modulesObjs[ 3 ] ).to.have.property( 'scoped', false );
187
+ // -------
188
+ document.body.appendChild( scoped );
189
+ expect( modulesObjs ).to.have.length( 5 );
190
+ expect( modulesObjs[ 4 ] ).to.have.property( 'scoped', true );
191
+ // -------
192
+ const unscoped = document.modules.temp0;
193
+ unscoped.remove();
194
+ document.head.appendChild( unscoped );
195
+ document.body.remove();
196
+ expect( modulesObjs ).to.have.length( 5 );
197
+ } );
198
+ } );
199
+
200
+ } );
@@ -1,51 +1,51 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { expect } from 'chai';
6
- import { createDocument, delay } from './index.js';
7
-
8
- describe(`Namespaced HTML`, function() {
9
-
10
- describe( `Basic...`, async function() {
11
-
12
- const head = `
13
- <meta name="oohtml" content="attr.id=id" />`;
14
- const body = `
15
- <div id="main" namespace>
16
- <div id="child"></div>
17
- </div>`;
18
- const { document, window } = createDocument( head, body );
19
- await delay( 60 );
20
- const { webqit: { Observer } } = window;
21
-
22
- it ( `The document object and elements should expose a "namespace" property each...`, async function() {
23
- expect( document ).to.have.property( 'namespace' );
24
- expect( document.namespace.main ).to.have.property( 'namespace' ).that.have.property( 'child' );
25
- } );
26
-
27
- it ( `Namespace objects should be observable...`, async function() {
28
- let idReceived = null;
29
- Observer.observe( document.namespace, records => {
30
- idReceived = records[ 0 ].key;
31
- } );
32
- const item = document.createElement( 'div' );
33
- item.setAttribute( 'id', 'some-id' );
34
- document.body.appendChild( item );
35
- expect( idReceived ).to.eq( 'some-id' );
36
- } );
37
-
38
- it ( `Namespace attributes should be applicable dynamically...`, async function() {
39
- expect( Object.keys( document.namespace ).length ).to.eq( 2 );
40
- document.body.toggleAttribute( 'namespace', true );
41
- expect( Object.keys( document.namespace ).length ).to.eq( 0 );
42
- expect( Object.keys( document.body.namespace ).length ).to.eq( 2 );
43
- document.body.toggleAttribute( 'namespace', false );
44
- expect( Object.keys( document.namespace ).length ).to.eq( 2 );
45
- expect( Object.keys( document.body.namespace ).length ).to.eq( 0 );
46
- } );
47
-
48
- } );
49
-
50
- } );
51
-
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import { expect } from 'chai';
6
+ import { createDocument, delay } from './index.js';
7
+
8
+ describe(`Namespaced HTML`, function() {
9
+
10
+ describe( `Basic...`, async function() {
11
+
12
+ const head = `
13
+ <meta name="oohtml" content="attr.id=id" />`;
14
+ const body = `
15
+ <div id="main" namespace>
16
+ <div id="child"></div>
17
+ </div>`;
18
+ const { document, window } = createDocument( head, body );
19
+ await delay( 60 );
20
+ const { webqit: { Observer } } = window;
21
+
22
+ it ( `The document object and elements should expose a "namespace" property each...`, async function() {
23
+ expect( document ).to.have.property( 'namespace' );
24
+ expect( document.namespace.main ).to.have.property( 'namespace' ).that.have.property( 'child' );
25
+ } );
26
+
27
+ it ( `Namespace objects should be observable...`, async function() {
28
+ let idReceived = null;
29
+ Observer.observe( document.namespace, records => {
30
+ idReceived = records[ 0 ].key;
31
+ } );
32
+ const item = document.createElement( 'div' );
33
+ item.setAttribute( 'id', 'some-id' );
34
+ document.body.appendChild( item );
35
+ expect( idReceived ).to.eq( 'some-id' );
36
+ } );
37
+
38
+ it ( `Namespace attributes should be applicable dynamically...`, async function() {
39
+ expect( Object.keys( document.namespace ).length ).to.eq( 2 );
40
+ document.body.toggleAttribute( 'namespace', true );
41
+ expect( Object.keys( document.namespace ).length ).to.eq( 0 );
42
+ expect( Object.keys( document.body.namespace ).length ).to.eq( 2 );
43
+ document.body.toggleAttribute( 'namespace', false );
44
+ expect( Object.keys( document.namespace ).length ).to.eq( 2 );
45
+ expect( Object.keys( document.body.namespace ).length ).to.eq( 0 );
46
+ } );
47
+
48
+ } );
49
+
50
+ } );
51
+
@@ -1,32 +1,32 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { expect } from 'chai';
6
- import { createDocument, delay } from './index.js';
7
-
8
- describe(`Test: Scoped CSS`, function() {
9
-
10
- describe(`Styles`, function() {
11
-
12
- it(`Should do basic rewrite`, async function() {
13
- const head = '', body = `
14
- <div>
15
- <h1>Hello World!</h1>
16
- <style scoped>
17
- h1 {
18
- color: red;
19
- }
20
- </style>
21
- </div>`;
22
-
23
- const window = createDocument( head, body );
24
- await delay( 160 ); // Takes time to dynamically load Subscript compiler
25
- const styleElement = window.document.querySelector( 'style' );
26
-
27
- expect( styleElement.textContent.substring( 0, 13 ) ).to.eq( '@scope from (' );
28
- });
29
-
30
- });
31
-
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import { expect } from 'chai';
6
+ import { createDocument, delay } from './index.js';
7
+
8
+ describe(`Test: Scoped CSS`, function() {
9
+
10
+ describe(`Styles`, function() {
11
+
12
+ it(`Should do basic rewrite`, async function() {
13
+ const head = '', body = `
14
+ <div>
15
+ <h1>Hello World!</h1>
16
+ <style scoped>
17
+ h1 {
18
+ color: red;
19
+ }
20
+ </style>
21
+ </div>`;
22
+
23
+ const window = createDocument( head, body );
24
+ await delay( 160 ); // Takes time to dynamically load Subscript compiler
25
+ const styleElement = window.document.querySelector( 'style' );
26
+
27
+ expect( styleElement.textContent.substring( 0, 13 ) ).to.eq( '@scope from (' );
28
+ });
29
+
30
+ });
31
+
32
32
  });
@@ -1,30 +1,30 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { expect } from 'chai';
6
- import { createDocument, delay } from './index.js';
7
-
8
- describe(`Test: Scoped JS`, function() {
9
-
10
- describe(`Scripts`, function() {
11
-
12
- it(`Should do basic observe`, async function() {
13
- const head = '', body = `
14
- <h1>Hello World!</h1>
15
- <script scoped contract>
16
- testRecords.push( this );
17
- console.log('-------scoped JS here.');
18
- </script>`;
19
-
20
- const window = createDocument( head, body );
21
- window.testRecords = [];
22
- await delay( 160 ); // Takes time to dynamically load Subscript compiler
23
-
24
- expect( window.testRecords ).to.have.length( 1 );
25
- expect( window.testRecords[ 0 ] ).to.eql( window.document.body );
26
- });
27
-
28
- });
29
-
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import { expect } from 'chai';
6
+ import { createDocument, delay } from './index.js';
7
+
8
+ describe(`Test: Scoped JS`, function() {
9
+
10
+ describe(`Scripts`, function() {
11
+
12
+ it(`Should do basic observe`, async function() {
13
+ const head = '', body = `
14
+ <h1>Hello World!</h1>
15
+ <script scoped contract>
16
+ testRecords.push( this );
17
+ console.log('-------scoped JS here.');
18
+ </script>`;
19
+
20
+ const window = createDocument( head, body );
21
+ window.testRecords = [];
22
+ await delay( 160 ); // Takes time to dynamically load Subscript compiler
23
+
24
+ expect( window.testRecords ).to.have.length( 1 );
25
+ expect( window.testRecords[ 0 ] ).to.eql( window.document.body );
26
+ });
27
+
28
+ });
29
+
30
30
  });