@lightningjs/blits 0.6.8 → 0.6.9

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ # v0.6.9
4
+
5
+ _31 jan 2024_
6
+
7
+ - Fixed single quote escaping for all browsers (removing sometimes unsupported negative lookahead)
8
+ - Fixed issue with focus when navigating back to a page that is kept in history
9
+
3
10
  # v0.6.8
4
11
 
5
12
  _29 jan 2024_
@@ -31,6 +31,6 @@
31
31
  "vite": "^4.0.4"
32
32
  },
33
33
  "dependencies": {
34
- "@lightningjs/blits": "^0.6.8"
34
+ "@lightningjs/blits": "^0.6.9"
35
35
  }
36
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.cjs",
6
6
  "exports": {
@@ -326,8 +326,12 @@ const cast = (val = '', key = false, component = 'component.') => {
326
326
  if (val.startsWith('$')) {
327
327
  castedValue = `${component}${val.replace('$', '')}`
328
328
  } else {
329
- // unescaped single quotes must be escaped
330
- castedValue = `'${parseInlineContent(val.replace(/(?<!\\)'/g, "\\'"), component)}'`
329
+ // unescaped single quotes must be escaped while preserving escaped backslashes
330
+ const escapedVal = val
331
+ .replace(/\\\\/g, '__DOUBLE_BACKSLASH__')
332
+ .replace(/(^|[^\\])'/g, "$1\\'")
333
+ .replace(/__DOUBLE_BACKSLASH__/g, '\\\\')
334
+ castedValue = `'${parseInlineContent(escapedVal, component)}'`
331
335
  }
332
336
  }
333
337
  // numeric
@@ -30,6 +30,7 @@ const cacheMap = new WeakMap()
30
30
  const history = []
31
31
  let overrideOptions = {}
32
32
  let navigatingBack = false
33
+ let previousFocus
33
34
 
34
35
  export const getHash = () => {
35
36
  return (document.location.hash || '/').replace(/^#/, '')
@@ -97,6 +98,12 @@ export const navigate = async function () {
97
98
 
98
99
  this[symbols.children].push(view)
99
100
 
101
+ // keep reference to the previous focus for storing in cache
102
+ previousFocus = Focus.get()
103
+
104
+ // set focus to the view that we're routing to
105
+ focus ? Focus.set(focus) : Focus.set(view)
106
+
100
107
  // apply before settings to holder element
101
108
  if (route.transition.before) {
102
109
  if (Array.isArray(route.transition.before)) {
@@ -143,8 +150,6 @@ export const navigate = async function () {
143
150
  Announcer.speak(route.announce.message, route.announce.politeness)
144
151
  }
145
152
 
146
- // focus the new view
147
- focus ? Focus.set(focus) : view.focus()
148
153
  this.activeView = this[symbols.children][this[symbols.children].length - 1]
149
154
  } else {
150
155
  Log.error(`Route ${hash} not found`)
@@ -172,7 +177,7 @@ const removeView = async (route, view, transition) => {
172
177
 
173
178
  // cache the page when it's as 'keepAlive' instead of destroying
174
179
  if (route.options && route.options.keepAlive === true) {
175
- cacheMap.set(route, { view: view, focus: Focus.get() })
180
+ cacheMap.set(route, { view: view, focus: previousFocus })
176
181
  } else {
177
182
  // remove and cleanup
178
183
  for (let i = 0; i < view[symbols.children].length - 1; i++) {