hypel 0.2.4 → 0.2.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.
Files changed (2) hide show
  1. package/hypel.js +8 -5
  2. package/package.json +1 -1
package/hypel.js CHANGED
@@ -85,14 +85,17 @@ const hypelsvg = h => {
85
85
  // div.properties.id; // hello
86
86
  const encodeid = idstr => idstr.replace(nsSepPlainRe, ':')
87
87
  const decodeid = idstr => idstr.replace(nsSepEncodeRe, '/')
88
- const tryprefix = (opts, classstr, prop) => (
89
- prop = opts[prop + 'prefix'],
88
+ const charCodeHyphen = 45 // the char "-"
89
+ const tryprefix = (opts, classstr, prop, prefixname) => (
90
+ prop = opts[prop + prefixname],
90
91
  prop && prop !== classstr ? prop + '.' + classstr : classstr)
91
92
  const getoptsclassidstr = (opts, classidstr, s) => (
92
- s = encodeid(classidstr.replace(nsKeyRe, m => (
93
+ s = encodeid(classidstr.replace(nsKeyRe, (m, offset, r) => (
93
94
  m = m.slice(1),
94
- // classidstr.charCodeAt(offset + m.length + 1) === charCodeHyphen
95
- tryprefix(opts, m in opts ? String(opts[m]) : m, m)
95
+ r = m in opts ? String(opts[m]) : m,
96
+ r = classidstr.charCodeAt(offset + m.length + 1) === charCodeHyphen
97
+ ? r : tryprefix(opts, r, m, 'root'),
98
+ tryprefix(opts, r, m, 'prefix')
96
99
  ))),
97
100
  s)
98
101
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hypel",
3
3
  "type": "module",
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
5
5
  "license": "MIT",
6
6
  "readmeFilename": "README.md",
7
7
  "description": "Terse syntax for hyperscript",