@webqit/webflo 0.20.40 → 0.20.42

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/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "vanila-javascript"
13
13
  ],
14
14
  "homepage": "https://webqit.io/tooling/webflo",
15
- "version": "0.20.40",
15
+ "version": "0.20.42",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
@@ -73,7 +73,10 @@ export class DeviceViewport {
73
73
 
74
74
  // 1. Handle Title
75
75
  if ('title' in state) {
76
- document.title = state.title || '';
76
+ const val = state.title || '';
77
+ if (document.title !== val) {
78
+ document.title = val;
79
+ }
77
80
  activeKeys.delete('title');
78
81
  }
79
82
 
@@ -118,20 +121,12 @@ export class DeviceViewport {
118
121
  });
119
122
 
120
123
  const vContent = viewportDirectives.join(', ');
121
- const vEl = this.#elements.viewport || (vContent ? this.#getOrCreate('viewport') : null);
122
- if (vEl) {
123
- vEl.setAttribute('content', vContent);
124
- if (!vContent && this.#ownedElements.has(vEl)) {
125
- vEl.remove();
126
- delete this.#elements.viewport;
127
- }
128
- }
124
+ this.#setAttr('viewport', vContent);
129
125
  }
130
126
 
131
- #setAttr(jsKey, val, media = null) {
132
- const cacheKey = media ? `${jsKey}-${media}` : jsKey;
127
+ #setAttr(jsKey, val, media = '') {
133
128
  const config = this.#specials[jsKey];
134
- const attrName = config.type === 'link' ? 'href' : 'content';
129
+ const attrName = config?.type === 'link' ? 'href' : 'content';
135
130
 
136
131
  if (val !== undefined && val !== null) {
137
132
  const el = this.#getOrCreate(jsKey, media);
@@ -139,6 +134,7 @@ export class DeviceViewport {
139
134
  el.setAttribute(attrName, val);
140
135
  }
141
136
  } else {
137
+ const cacheKey = media ? `${jsKey}-${media}` : jsKey;
142
138
  const el = this.#elements[cacheKey];
143
139
  if (el) {
144
140
  if (this.#ownedElements.has(el)) {
@@ -163,13 +159,15 @@ export class DeviceViewport {
163
159
  this.#scheduleRender();
164
160
  }
165
161
 
166
- pop(id) {
167
- if (!id) throw new Error("pop() requires a target ID");
168
- const idx = this.#stack.findIndex(e => e.id === id);
169
- if (idx > 0) { // Never pop the initial state at index 0
170
- this.#stack.splice(idx, 1);
171
- this.#scheduleRender();
172
- }
162
+ pop(...ids) {
163
+ if (!ids.length) throw new Error("pop() requires a target ID");
164
+ ids.forEach((id) => {
165
+ const idx = this.#stack.findIndex(e => e.id === id);
166
+ if (idx > 0) { // Never pop the initial state at index 0
167
+ this.#stack.splice(idx, 1);
168
+ }
169
+ });
170
+ this.#scheduleRender();
173
171
  }
174
172
 
175
173
  peek() { return this.#stack[this.#stack.length - 1]; }
@@ -498,8 +498,6 @@ export class ModalElement extends BaseElement {
498
498
  };
499
499
 
500
500
  const observer = new IntersectionObserver((entries) => {
501
- if (!this.#userScrolled) return;
502
-
503
501
  for (const entry of entries) {
504
502
  // Minmax events
505
503
  if (entry.target === this.#spacingElement) {
@@ -508,7 +506,8 @@ export class ModalElement extends BaseElement {
508
506
  }
509
507
 
510
508
  // For auto-closing
511
- if (entry.target === this.#sentinelElement
509
+ if (this.#userScrolled
510
+ && entry.target === this.#sentinelElement
512
511
  && entry.isIntersecting
513
512
  && entry.intersectionRatio >= 0.8) {
514
513
  this.hidePopover();