Skip to content

Commit 6388603

Browse files
committed
Merge pull request #175 from bhamodi/baraa/release-1.1.2
[RELEASE] 1.1.2
2 parents 0d59927 + 9b37a98 commit 6388603

File tree

5 files changed

+72
-35
lines changed

5 files changed

+72
-35
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.2 (October 5, 2015)
2+
3+
- **[FIXED]** Fix for observer iteration when removed during notify. [Issue #151](https://github.com/optimizely/nuclear-js/issues/151)
4+
15
## 1.1.1 (July 26, 2015)
26

37
- **[ADDED]** Bowser support via bower.json

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuclear-js",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"homepage": "https://github.com/optimizely/nuclear-js",
55
"authors": [
66
"Jordan Garcia"

dist/nuclear.js

+63-30
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
if(typeof exports === 'object' && typeof module === 'object')
33
module.exports = factory();
44
else if(typeof define === 'function' && define.amd)
5-
define(factory);
5+
define([], factory);
66
else if(typeof exports === 'object')
77
exports["Nuclear"] = factory();
88
else
@@ -220,7 +220,21 @@ return /******/ (function(modules) { // webpackBootstrap
220220
}
221221

222222
function wrapIndex(iter, index) {
223-
return index >= 0 ? (+index) : ensureSize(iter) + (+index);
223+
// This implements "is array index" which the ECMAString spec defines as:
224+
// A String property name P is an array index if and only if
225+
// ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
226+
// to 2^32−1.
227+
// However note that we're currently calling ToNumber() instead of ToUint32()
228+
// which should be improved in the future, as floating point numbers should
229+
// not be accepted as an array index.
230+
if (typeof index !== 'number') {
231+
var numIndex = +index;
232+
if ('' + numIndex !== index) {
233+
return NaN;
234+
}
235+
index = numIndex;
236+
}
237+
return index < 0 ? ensureSize(iter) + index : index;
224238
}
225239

226240
function returnTrue() {
@@ -890,7 +904,7 @@ return /******/ (function(modules) { // webpackBootstrap
890904
var src_Math__imul =
891905
typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
892906
Math.imul :
893-
function src_Math__imul(a, b) {
907+
function imul(a, b) {
894908
a = a | 0; // int
895909
b = b | 0; // int
896910
var c = a & 0xffff;
@@ -1441,6 +1455,15 @@ return /******/ (function(modules) { // webpackBootstrap
14411455
function sliceFactory(iterable, begin, end, useKeys) {
14421456
var originalSize = iterable.size;
14431457

1458+
// Sanitize begin & end using this shorthand for ToInt32(argument)
1459+
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
1460+
if (begin !== undefined) {
1461+
begin = begin | 0;
1462+
}
1463+
if (end !== undefined) {
1464+
end = end | 0;
1465+
}
1466+
14441467
if (wholeSlice(begin, end, originalSize)) {
14451468
return iterable;
14461469
}
@@ -1467,7 +1490,9 @@ return /******/ (function(modules) { // webpackBootstrap
14671490

14681491
var sliceSeq = makeSequence(iterable);
14691492

1470-
sliceSeq.size = sliceSize;
1493+
// If iterable.size is undefined, the size of the realized sliceSeq is
1494+
// unknown at this point unless the number of items to slice is 0
1495+
sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
14711496

14721497
if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
14731498
sliceSeq.get = function (index, notSetValue) {
@@ -1916,7 +1941,7 @@ return /******/ (function(modules) { // webpackBootstrap
19161941

19171942
function src_Map__Map(value) {
19181943
return value === null || value === undefined ? emptyMap() :
1919-
isMap(value) ? value :
1944+
isMap(value) && !isOrdered(value) ? value :
19201945
emptyMap().withMutations(function(map ) {
19211946
var iter = KeyedIterable(value);
19221947
assertNotInfinite(iter.size);
@@ -2763,12 +2788,12 @@ return /******/ (function(modules) { // webpackBootstrap
27632788

27642789
List.prototype.get = function(index, notSetValue) {
27652790
index = wrapIndex(this, index);
2766-
if (index < 0 || index >= this.size) {
2767-
return notSetValue;
2791+
if (index >= 0 && index < this.size) {
2792+
index += this._origin;
2793+
var node = listNodeFor(this, index);
2794+
return node && node.array[index & MASK];
27682795
}
2769-
index += this._origin;
2770-
var node = listNodeFor(this, index);
2771-
return node && node.array[index & MASK];
2796+
return notSetValue;
27722797
};
27732798

27742799
// @pragma Modification
@@ -2964,29 +2989,25 @@ return /******/ (function(modules) { // webpackBootstrap
29642989
};
29652990

29662991
VNode.prototype.removeAfter = function(ownerID, level, index) {
2967-
if (index === level ? 1 << level : 0 || this.array.length === 0) {
2992+
if (index === (level ? 1 << level : 0) || this.array.length === 0) {
29682993
return this;
29692994
}
29702995
var sizeIndex = ((index - 1) >>> level) & MASK;
29712996
if (sizeIndex >= this.array.length) {
29722997
return this;
29732998
}
2974-
var removingLast = sizeIndex === this.array.length - 1;
2999+
29753000
var newChild;
29763001
if (level > 0) {
29773002
var oldChild = this.array[sizeIndex];
29783003
newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
2979-
if (newChild === oldChild && removingLast) {
3004+
if (newChild === oldChild && sizeIndex === this.array.length - 1) {
29803005
return this;
29813006
}
29823007
}
2983-
if (removingLast && !newChild) {
2984-
return this;
2985-
}
3008+
29863009
var editable = editableVNode(this, ownerID);
2987-
if (!removingLast) {
2988-
editable.array.pop();
2989-
}
3010+
editable.array.splice(sizeIndex + 1);
29903011
if (newChild) {
29913012
editable.array[sizeIndex] = newChild;
29923013
}
@@ -3078,6 +3099,10 @@ return /******/ (function(modules) { // webpackBootstrap
30783099
function updateList(list, index, value) {
30793100
index = wrapIndex(list, index);
30803101

3102+
if (index !== index) {
3103+
return list;
3104+
}
3105+
30813106
if (index >= list.size || index < 0) {
30823107
return list.withMutations(function(list ) {
30833108
index < 0 ?
@@ -3169,6 +3194,14 @@ return /******/ (function(modules) { // webpackBootstrap
31693194
}
31703195

31713196
function setListBounds(list, begin, end) {
3197+
// Sanitize begin & end using this shorthand for ToInt32(argument)
3198+
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
3199+
if (begin !== undefined) {
3200+
begin = begin | 0;
3201+
}
3202+
if (end !== undefined) {
3203+
end = end | 0;
3204+
}
31723205
var owner = list.__ownerID || new OwnerID();
31733206
var oldOrigin = list._origin;
31743207
var oldCapacity = list._capacity;
@@ -3681,7 +3714,7 @@ return /******/ (function(modules) { // webpackBootstrap
36813714

36823715
function src_Set__Set(value) {
36833716
return value === null || value === undefined ? emptySet() :
3684-
isSet(value) ? value :
3717+
isSet(value) && !isOrdered(value) ? value :
36853718
emptySet().withMutations(function(set ) {
36863719
var iter = SetIterable(value);
36873720
assertNotInfinite(iter.size);
@@ -4426,10 +4459,6 @@ return /******/ (function(modules) { // webpackBootstrap
44264459
return reify(this, concatFactory(this, values));
44274460
},
44284461

4429-
contains: function(searchValue) {
4430-
return this.includes(searchValue);
4431-
},
4432-
44334462
includes: function(searchValue) {
44344463
return this.some(function(value ) {return is(value, searchValue)});
44354464
},
@@ -4719,7 +4748,7 @@ return /******/ (function(modules) { // webpackBootstrap
47194748

47204749
hashCode: function() {
47214750
return this.__hash || (this.__hash = hashIterable(this));
4722-
},
4751+
}
47234752

47244753

47254754
// ### Internal
@@ -4742,6 +4771,7 @@ return /******/ (function(modules) { // webpackBootstrap
47424771
IterablePrototype.inspect =
47434772
IterablePrototype.toSource = function() { return this.toString(); };
47444773
IterablePrototype.chain = IterablePrototype.flatMap;
4774+
IterablePrototype.contains = IterablePrototype.includes;
47454775

47464776
// Temporary warning about using length
47474777
(function () {
@@ -4812,7 +4842,7 @@ return /******/ (function(modules) { // webpackBootstrap
48124842
function(k, v) {return mapper.call(context, k, v, this$0)}
48134843
).flip()
48144844
);
4815-
},
4845+
}
48164846

48174847
});
48184848

@@ -4867,7 +4897,10 @@ return /******/ (function(modules) { // webpackBootstrap
48674897
if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
48684898
return this;
48694899
}
4870-
index = resolveBegin(index, this.size);
4900+
// If index is negative, it should resolve relative to the size of the
4901+
// collection. However size may be expensive to compute if not cached, so
4902+
// only call count() if the number is in fact negative.
4903+
index = resolveBegin(index, index < 0 ? this.count() : this.size);
48714904
var spliced = this.slice(0, index);
48724905
return reify(
48734906
this,
@@ -4940,7 +4973,7 @@ return /******/ (function(modules) { // webpackBootstrap
49404973
var iterables = arrCopy(arguments);
49414974
iterables[0] = this;
49424975
return reify(this, zipWithFactory(this, zipper, iterables));
4943-
},
4976+
}
49444977

49454978
});
49464979

@@ -4966,7 +4999,7 @@ return /******/ (function(modules) { // webpackBootstrap
49664999

49675000
keySeq: function() {
49685001
return this.valueSeq();
4969-
},
5002+
}
49705003

49715004
});
49725005

@@ -5070,7 +5103,7 @@ return /******/ (function(modules) { // webpackBootstrap
50705103
Repeat: Repeat,
50715104

50725105
is: is,
5073-
fromJS: fromJS,
5106+
fromJS: fromJS
50745107

50755108
};
50765109

dist/nuclear.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nuclear-js",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Immutable, reactive Flux architecture. UI Agnostic.",
55
"main": "dist/nuclear.js",
66
"scripts": {

0 commit comments

Comments
 (0)