enigmatic 0.21.4 → 0.21.5
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/enigmatic.css +1 -0
- package/enigmatic.js +12 -1
- package/package.json +1 -1
- package/tests/test.html +28 -0
- package/tests/test-authn.html +0 -0
- package/tests/test-element-classic.html +0 -14
- package/tests/test-icons.html +0 -3
- package/tests/test-state.html +0 -6
- package/tests/test.mjs +0 -26
package/enigmatic.css
CHANGED
package/enigmatic.js
CHANGED
|
@@ -154,7 +154,18 @@ w.start = async () => {
|
|
|
154
154
|
[...e.attributes].map((a) => (e.attr[a.name] = a.value))
|
|
155
155
|
if (e.attr.fetch) {
|
|
156
156
|
e.fetch = async () => {
|
|
157
|
-
|
|
157
|
+
let template = e.innerHTML
|
|
158
|
+
let ignore = template.match(/<!--IGNORE-->.*>/gms) || ''
|
|
159
|
+
if(ignore)
|
|
160
|
+
template = template.replace(ignore, '')
|
|
161
|
+
const obj = await w.get(e.attr.fetch, {}, null, e.attr.data)
|
|
162
|
+
e.innerHTML = w.flatten(obj, template) + ignore
|
|
163
|
+
let pos = 0
|
|
164
|
+
for(c in e.children) {
|
|
165
|
+
if('set' in e.children[c])
|
|
166
|
+
e.children[c].set(obj[pos++])
|
|
167
|
+
}
|
|
168
|
+
return obj
|
|
158
169
|
}
|
|
159
170
|
if (!e.hasAttribute('defer'))
|
|
160
171
|
e.fetch()
|
package/package.json
CHANGED
package/tests/test.html
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<script src='../enigmatic.js'></script>
|
|
2
|
+
<script src='../components.js'></script>
|
|
3
|
+
<link rel='stylesheet' href='../enigmatic.css'>
|
|
4
|
+
|
|
5
|
+
<body style="--cols:1fr 10fr 1fr; --rows:1fr">
|
|
6
|
+
<div class="bg-black">a</div>
|
|
7
|
+
<section class="bg-white">
|
|
8
|
+
|
|
9
|
+
<div id='par' fetch='[{"id": 1, "control": "input"},{"id": 2, "control": "select"}]'>
|
|
10
|
+
<div>{control}</div>
|
|
11
|
+
<test-element id="{id}"></test-element>
|
|
12
|
+
<br>
|
|
13
|
+
<!--IGNORE-->
|
|
14
|
+
ignore this
|
|
15
|
+
<!--ENDIGNORE-->
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
</section>
|
|
19
|
+
<div class="bg-yellow"></div>
|
|
20
|
+
</body>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
customElements.define('test-element', class extends HTMLElement {
|
|
24
|
+
set(o) {
|
|
25
|
+
this.innerHTML = `<${o.control}></${o.control}>`
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
</script>
|
package/tests/test-authn.html
DELETED
|
File without changes
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<script src='../enigmatic.js'></script>
|
|
2
|
-
|
|
3
|
-
<script type="module">
|
|
4
|
-
|
|
5
|
-
customElements.define('classic-syntax', class CS extends HTMLElement {
|
|
6
|
-
set(data) {
|
|
7
|
-
this.innerHTML = flatten(data, this.innerHTML)
|
|
8
|
-
}
|
|
9
|
-
})
|
|
10
|
-
state.mykey = {message: 'somedata'}
|
|
11
|
-
|
|
12
|
-
</script>
|
|
13
|
-
|
|
14
|
-
<classic-syntax data="mykey">{message}</classic-syntax>
|
package/tests/test-icons.html
DELETED
package/tests/test-state.html
DELETED
package/tests/test.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// wsl install:
|
|
2
|
-
// wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
|
|
3
|
-
// sudo apt - y install./ google - chrome - stable_current_amd64.deb
|
|
4
|
-
|
|
5
|
-
import puppeteer from 'puppeteer'
|
|
6
|
-
import { te, tde, tm, wait } from 'instax'
|
|
7
|
-
const host = 'http://127.0.0.1:8080'
|
|
8
|
-
|
|
9
|
-
const browser = await puppeteer.launch({ headless: true })
|
|
10
|
-
const page = await browser.newPage()
|
|
11
|
-
await page.goto(`${host}/test.html`, {
|
|
12
|
-
waitUntil: 'networkidle2',
|
|
13
|
-
timeout: 5000
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const e = (await page.evaluate("enigmatic"))
|
|
17
|
-
tm(e.version, /0.11.1/)
|
|
18
|
-
tm(await page.evaluate("$('#div1').template"), /results/)
|
|
19
|
-
|
|
20
|
-
// get
|
|
21
|
-
// state
|
|
22
|
-
// div
|
|
23
|
-
// custom
|
|
24
|
-
await wait(2000)
|
|
25
|
-
await page.close()
|
|
26
|
-
await browser.close()
|