Commit 3f950d344b2e9e7cd202b465ec4e3ca15225155b
computed: null should not be detected as reference type
Matt McKegg committed on 7/15/2016, 3:06:58 AMParent: 2244524e466413910788cad98baa61df4f340866
Files changed
computed.js | changed |
computed.js | ||
---|---|---|
@@ -57,9 +57,9 @@ | ||
57 | 57 … | |
58 | 58 … | function listen () { |
59 | 59 … | if (!live) { |
60 | 60 … | for (var i = 0, len = observables.length; i < len; i++) { |
61 | - if (typeof observables[i] === 'function') { | |
61 … | + if (isObservable(observables[i])) { | |
62 | 62 … | releases.push(observables[i](onUpdate)) |
63 | 63 … | } |
64 | 64 … | } |
65 | 65 … | if (inner) { |
@@ -88,18 +88,18 @@ | ||
88 | 88 … | function update () { |
89 | 89 … | var changed = false |
90 | 90 … | for (var i = 0, len = observables.length; i < len; i++) { |
91 | 91 … | var newValue = resolve(observables[i]) |
92 | - if (newValue !== values[i] || typeof newValue === 'object') { | |
92 … | + if (newValue !== values[i] || isReferenceType(newValue)) { | |
93 | 93 … | changed = true |
94 | 94 … | values[i] = newValue |
95 | 95 … | } |
96 | 96 … | } |
97 | 97 … | |
98 | 98 … | if (changed || !initialized) { |
99 | 99 … | initialized = true |
100 | 100 … | var newComputedValue = lambda.apply(null, values) |
101 | - if (newComputedValue !== computedValue || (typeof newComputedValue === 'object' && !isObservable(newComputedValue))) { | |
101 … | + if (newComputedValue !== computedValue || (isReferenceType(newComputedValue) && !isObservable(newComputedValue))) { | |
102 | 102 … | if (releaseInner) { |
103 | 103 … | releaseInner() |
104 | 104 … | inner = releaseInner = null |
105 | 105 … | } |
@@ -120,9 +120,9 @@ | ||
120 | 120 … | return false |
121 | 121 … | } |
122 | 122 … | |
123 | 123 … | function onInnerUpdate (value) { |
124 | - if (value !== computedValue || typeof newComputedValue === 'object') { | |
124 … | + if (value !== computedValue || isReferenceType(computedValue)) { | |
125 | 125 … | computedValue = value |
126 | 126 … | for (var i = 0, len = listeners.length; i < len; i++) { |
127 | 127 … | listeners[i](computedValue) |
128 | 128 … | } |
@@ -144,4 +144,8 @@ | ||
144 | 144 … | } |
145 | 145 … | return computedValue |
146 | 146 … | } |
147 | 147 … | } |
148 … | + | |
149 … | +function isReferenceType (value) { | |
150 … | + return typeof value === 'object' && value !== null | |
151 … | +} |
Built with git-ssb-web