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 CHANGED
@@ -32,6 +32,7 @@ ol {
32
32
  }
33
33
 
34
34
  body,
35
+ home,
35
36
  section {
36
37
  display: grid;
37
38
  margin: 0;
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
- return w.get(e.attr.fetch, {}, null, e.attr.data)
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "enigmatic",
3
3
  "main": "enigmatic.js",
4
- "version": "0.21.4",
4
+ "version": "0.21.5",
5
5
  "scripts": {
6
6
  "test": "node test.mjs"
7
7
  },
@@ -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>
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>
@@ -1,3 +0,0 @@
1
- <img height='62'
2
- style='filter: invert(64%) sepia(73%) saturate(2067%) hue-rotate(156deg) brightness(87%) contrast(103%)'
3
- src='https://unpkg.com/simple-icons@v7/icons/apple.svg'>
@@ -1,6 +0,0 @@
1
- <script src='../enigmatic.js'></script>
2
-
3
- <div data="mykey" value="1"></div>
4
- <button onclick="state.mykey++">Increment</button>
5
-
6
- <div data='mymessage' fetch='{"messages": "ok"}'>{messages}</div>
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()