@webqit/webflo 0.20.38 → 0.20.40
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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class DeviceViewport {
|
|
1
|
+
export class DeviceViewport {
|
|
2
2
|
|
|
3
3
|
#stack = [];
|
|
4
4
|
#ownedElements = new Set(); // Stores elements created by this class
|
|
@@ -69,7 +69,7 @@ class DeviceViewport {
|
|
|
69
69
|
#render() {
|
|
70
70
|
const state = this.peek();
|
|
71
71
|
const viewportDirectives = [];
|
|
72
|
-
const activeKeys = new Set(Object.keys(state).filter(k => !k.startsWith('_')));
|
|
72
|
+
const activeKeys = new Set(Object.keys(state).filter(k => k !== 'id' && !k.startsWith('_')));
|
|
73
73
|
|
|
74
74
|
// 1. Handle Title
|
|
75
75
|
if ('title' in state) {
|
|
@@ -131,18 +131,21 @@ class DeviceViewport {
|
|
|
131
131
|
#setAttr(jsKey, val, media = null) {
|
|
132
132
|
const cacheKey = media ? `${jsKey}-${media}` : jsKey;
|
|
133
133
|
const config = this.#specials[jsKey];
|
|
134
|
+
const attrName = config.type === 'link' ? 'href' : 'content';
|
|
134
135
|
|
|
135
136
|
if (val !== undefined && val !== null) {
|
|
136
137
|
const el = this.#getOrCreate(jsKey, media);
|
|
137
|
-
el.
|
|
138
|
+
if (el.getAttribute(attrName) !== val) {
|
|
139
|
+
el.setAttribute(attrName, val);
|
|
140
|
+
}
|
|
138
141
|
} else {
|
|
139
142
|
const el = this.#elements[cacheKey];
|
|
140
143
|
if (el) {
|
|
141
144
|
if (this.#ownedElements.has(el)) {
|
|
142
145
|
el.remove();
|
|
143
146
|
delete this.#elements[cacheKey];
|
|
144
|
-
} else {
|
|
145
|
-
el.setAttribute(
|
|
147
|
+
} else if (el.getAttribute(attrName) !== '') {
|
|
148
|
+
el.setAttribute(attrName, '');
|
|
146
149
|
}
|
|
147
150
|
}
|
|
148
151
|
}
|
|
@@ -150,7 +153,7 @@ class DeviceViewport {
|
|
|
150
153
|
|
|
151
154
|
#parseViewport = (c) => Object.fromEntries(c.split(',').filter(Boolean).map(s => {
|
|
152
155
|
const [k, v] = s.split('=').map(p => p.trim());
|
|
153
|
-
return [k.replace(/-([a-z])/g, g => g.toUpperCase()), v || true];
|
|
156
|
+
return [k.replace(/-([a-z])/g, g => g[1].toUpperCase()), v || true];
|
|
154
157
|
}));
|
|
155
158
|
|
|
156
159
|
push(id, config) {
|