@dinoreic/fez 0.4.0 → 0.4.1
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/README.md +30 -3
- package/dist/fez.js +8 -8
- package/dist/fez.js.map +3 -3
- package/package.json +1 -1
- package/src/fez/connect.js +7 -3
- package/src/fez/defaults.js +11 -0
- package/src/fez/instance.js +9 -9
- package/src/fez/root.js +51 -1
- package/src/rollup.js +1 -1
- package/src/svelte-cde-adapter.coffee +11 -10
package/package.json
CHANGED
package/src/fez/connect.js
CHANGED
|
@@ -111,10 +111,14 @@ export default function connect(name, klass) {
|
|
|
111
111
|
function useFastRender(node, klass) {
|
|
112
112
|
const fezFast = node.getAttribute('fez-fast')
|
|
113
113
|
var isFast = typeof klass.FAST === 'function' ? klass.FAST(node) : klass.FAST
|
|
114
|
-
if (fezFast
|
|
114
|
+
if (fezFast || isFast || node.childNodes[0] || node.nextSibling) {
|
|
115
|
+
return true
|
|
116
|
+
}
|
|
117
|
+
else if (fezFast == 'false') {
|
|
118
|
+
return false
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
115
121
|
return false
|
|
116
|
-
} else {
|
|
117
|
-
return fezFast || isFast
|
|
118
122
|
}
|
|
119
123
|
}
|
|
120
124
|
|
package/src/fez/defaults.js
CHANGED
|
@@ -54,6 +54,17 @@ const loadDefaults = () => {
|
|
|
54
54
|
}
|
|
55
55
|
})
|
|
56
56
|
|
|
57
|
+
// Show node only if test validates
|
|
58
|
+
// <fez-if if="window.foo">...
|
|
59
|
+
Fez('fez-if', class {
|
|
60
|
+
init(props) {
|
|
61
|
+
const test = new Function(`return (${props.if || props.test})`)
|
|
62
|
+
if (!test()) {
|
|
63
|
+
this.root.remove()
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
|
|
57
68
|
// Memory store for memoization
|
|
58
69
|
const memoStore = new Map()
|
|
59
70
|
|
package/src/fez/instance.js
CHANGED
|
@@ -130,13 +130,11 @@ export default class FezBase {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
if (
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.root[name] = value
|
|
139
|
-
}
|
|
133
|
+
if (typeof value == 'string') {
|
|
134
|
+
this.root.setAttribute(name, value)
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
this.root[name] = value
|
|
140
138
|
}
|
|
141
139
|
}
|
|
142
140
|
}
|
|
@@ -671,8 +669,10 @@ export default class FezBase {
|
|
|
671
669
|
obj ||= {}
|
|
672
670
|
|
|
673
671
|
handler ||= (o, k, v, oldValue) => {
|
|
674
|
-
|
|
675
|
-
|
|
672
|
+
if (v != oldValue) {
|
|
673
|
+
this.onStateChange(k, v, oldValue)
|
|
674
|
+
this.nextTick(this.render, 'render')
|
|
675
|
+
}
|
|
676
676
|
}
|
|
677
677
|
|
|
678
678
|
handler.bind(this)
|
package/src/fez/root.js
CHANGED
|
@@ -134,12 +134,62 @@ Fez.morphdom = (target, newNode, opts = {}) => {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
Fez._globalSubs ||= new Map()
|
|
138
|
+
|
|
137
139
|
Fez.publish = (channel, ...args) => {
|
|
138
140
|
Fez._subs ||= {}
|
|
139
141
|
Fez._subs[channel] ||= []
|
|
140
142
|
Fez._subs[channel].forEach((el) => {
|
|
141
143
|
el[1].bind(el[0])(...args)
|
|
142
144
|
})
|
|
145
|
+
|
|
146
|
+
// Trigger global subscriptions
|
|
147
|
+
const subs = Fez._globalSubs.get(channel)
|
|
148
|
+
if (subs) {
|
|
149
|
+
subs.forEach((sub) => {
|
|
150
|
+
if (sub.node.isConnected) {
|
|
151
|
+
sub.callback.call(sub.node, ...args)
|
|
152
|
+
} else {
|
|
153
|
+
// Remove disconnected nodes from subscriptions
|
|
154
|
+
subs.delete(sub)
|
|
155
|
+
}
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
Fez.subscribe = (node, eventName, callback) => {
|
|
161
|
+
// If second arg is function, shift arguments
|
|
162
|
+
if (typeof eventName === 'function') {
|
|
163
|
+
callback = eventName
|
|
164
|
+
eventName = node
|
|
165
|
+
node = document.body
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Handle string selectors
|
|
169
|
+
if (typeof node === 'string') {
|
|
170
|
+
node = document.querySelector(node)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!Fez._globalSubs.has(eventName)) {
|
|
174
|
+
Fez._globalSubs.set(eventName, new Set())
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const subs = Fez._globalSubs.get(eventName)
|
|
178
|
+
|
|
179
|
+
// Remove existing subscription for same node and callback
|
|
180
|
+
subs.forEach(sub => {
|
|
181
|
+
if (sub.node === node && sub.callback === callback) {
|
|
182
|
+
subs.delete(sub)
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
const subscription = { node, callback }
|
|
187
|
+
subs.add(subscription)
|
|
188
|
+
|
|
189
|
+
// Return unsubscribe function
|
|
190
|
+
return () => {
|
|
191
|
+
subs.delete(subscription)
|
|
192
|
+
}
|
|
143
193
|
}
|
|
144
194
|
|
|
145
195
|
Fez.error = (text, show) => {
|
|
@@ -197,7 +247,7 @@ cssMixin(Fez)
|
|
|
197
247
|
Fez.compile = compile
|
|
198
248
|
Fez.state = state
|
|
199
249
|
Fez.dump = objectDump
|
|
200
|
-
Fez.
|
|
250
|
+
Fez.highlightAll = highlightAll
|
|
201
251
|
|
|
202
252
|
Fez.onReady(() => {
|
|
203
253
|
Fez.log('Fez.LOG === true, logging enabled.')
|
package/src/rollup.js
CHANGED
|
@@ -13,7 +13,7 @@ const transformFez = (code, filePath) => {
|
|
|
13
13
|
const baseName = filePath.split('/').pop().split('.');
|
|
14
14
|
|
|
15
15
|
if (baseName[1] === 'fez') {
|
|
16
|
-
code = code.replace(/`/g, '\\`').replace(/\$/g, '\\$');
|
|
16
|
+
code = code.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$/g, '\\$');
|
|
17
17
|
return `Fez.compile('${baseName[0]}', \`\n${code}\`)`;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -100,18 +100,19 @@ Svelte.connect = (name, klass) ->
|
|
|
100
100
|
# %s-menu-vertical{ fast_connect: true }
|
|
101
101
|
|
|
102
102
|
# connect @, name, klass
|
|
103
|
-
# if @firstChild && (klass.prototype.hasOwnProperty('fast') || @getAttribute('fast_connect') || @getAttribute('data-props') || @getAttribute('data-json-template'))
|
|
104
|
-
# connect @, name, klass
|
|
105
|
-
# else
|
|
106
|
-
# requestAnimationFrame =>
|
|
107
|
-
# connect @, name, klass
|
|
108
103
|
|
|
109
|
-
if
|
|
110
|
-
|
|
111
|
-
=> connect(@, name, klass)
|
|
112
|
-
, once: true
|
|
104
|
+
if this.childNodes[0] || this.nextSibling || klass.prototype.hasOwnProperty('fast') || klass.prototype.hasOwnProperty('FAST') || @getAttribute('fast_connect') || @getAttribute('data-props') || @getAttribute('data-json-template')
|
|
105
|
+
connect @, name, klass
|
|
113
106
|
else
|
|
114
|
-
|
|
107
|
+
requestAnimationFrame =>
|
|
108
|
+
connect @, name, klass
|
|
109
|
+
|
|
110
|
+
# if document.readyState == 'loading'
|
|
111
|
+
# document.addEventListener 'DOMContentLoaded',
|
|
112
|
+
# => connect(@, name, klass)
|
|
113
|
+
# , once: true
|
|
114
|
+
# else
|
|
115
|
+
# connect(@, name, klass)
|
|
115
116
|
|
|
116
117
|
# Creates HTML tag
|
|
117
118
|
Svelte.tag = (tag, opts = {}, html = '') ->
|