git ssb

1+

Matt McKegg / mutant



Commit 3f950d344b2e9e7cd202b465ec4e3ca15225155b

computed: null should not be detected as reference type

Matt McKegg committed on 7/15/2016, 3:06:58 AM
Parent: 2244524e466413910788cad98baa61df4f340866

Files changed

computed.jschanged
computed.jsView
@@ -57,9 +57,9 @@
5757
5858 function listen () {
5959 if (!live) {
6060 for (var i = 0, len = observables.length; i < len; i++) {
61- if (typeof observables[i] === 'function') {
61 + if (isObservable(observables[i])) {
6262 releases.push(observables[i](onUpdate))
6363 }
6464 }
6565 if (inner) {
@@ -88,18 +88,18 @@
8888 function update () {
8989 var changed = false
9090 for (var i = 0, len = observables.length; i < len; i++) {
9191 var newValue = resolve(observables[i])
92- if (newValue !== values[i] || typeof newValue === 'object') {
92 + if (newValue !== values[i] || isReferenceType(newValue)) {
9393 changed = true
9494 values[i] = newValue
9595 }
9696 }
9797
9898 if (changed || !initialized) {
9999 initialized = true
100100 var newComputedValue = lambda.apply(null, values)
101- if (newComputedValue !== computedValue || (typeof newComputedValue === 'object' && !isObservable(newComputedValue))) {
101 + if (newComputedValue !== computedValue || (isReferenceType(newComputedValue) && !isObservable(newComputedValue))) {
102102 if (releaseInner) {
103103 releaseInner()
104104 inner = releaseInner = null
105105 }
@@ -120,9 +120,9 @@
120120 return false
121121 }
122122
123123 function onInnerUpdate (value) {
124- if (value !== computedValue || typeof newComputedValue === 'object') {
124 + if (value !== computedValue || isReferenceType(computedValue)) {
125125 computedValue = value
126126 for (var i = 0, len = listeners.length; i < len; i++) {
127127 listeners[i](computedValue)
128128 }
@@ -144,4 +144,8 @@
144144 }
145145 return computedValue
146146 }
147147 }
148 +
149 +function isReferenceType (value) {
150 + return typeof value === 'object' && value !== null
151 +}

Built with git-ssb-web