OLD | NEW |
| (Empty) |
1 ## Caution! | |
2 | |
3 Here you will find points of caution when updating Sugar to a new version. | |
4 Think of it as a pruned Changelog with the most front-facing changes surfaced. | |
5 If your code breaks on update check here first! Read all the ones that are great
er than the version you are migrating from. | |
6 | |
7 ### Note about versions < 1.3.9 | |
8 | |
9 Version 1.4.0 improves future-compatibility by ensuring that browser updates do
not cause breakages going forward. Upgrading is highly recommended, however as t
here are also many API changes, [this patch](https://raw.github.com/andrewplumme
r/Sugar/master/lib/patches/sugar-es6-patch.min.js) was created for older version
s. Just drop it in after the main script. | |
10 | |
11 | |
12 | |
13 v1.4.1+ | |
14 ======= | |
15 | |
16 - Level: Minor | |
17 - `Object.select` and `Object.reject` now will match values when passed an obj
ect. This means that if you pass `{foo:'bar'}`, it will no longer match if the v
alue of `foo` in your object is not `bar`. Previously it would match simply if t
he key existed. | |
18 | |
19 | |
20 v1.4.0+ | |
21 ======= | |
22 | |
23 - Level: Major | |
24 - `pad`, `padLeft`, and `padRight` now pad to the exact character. This means
that `padLeft(20)` will produce a string exactly 20 characters long, instead of
adding 20 characters worth of padding to the left side of the string as before.
You can use `String#repeat` for the same effect as the old functionality. | |
25 | |
26 - Level: Major | |
27 - `Object.fromQueryString` now does not cast values by default. This means tha
t all values in the resulting object are strings, unless `castBoolean` is true,
which will cast boolean values of "true" and "false" only. Digits are no longer
cast to numbers at all. Additionally, the "deep" argument is now removed. Deep p
arameters will always be parsed if they can be. | |
28 | |
29 - Level: Major | |
30 - `Function#lazy` now has different arguments. `limit` is now the third argume
nt with `immediate` taking its place as second. Additionally `immediate` -- whic
h determines whether lazy functions are executed immediately then lock or lock t
hen execute after a timeout -- is now false by default. | |
31 | |
32 - Level: Major | |
33 - Date range methods `eachDay`, `eachMonth`, etc. are deprecated in favor of t
he syntax `every("day")`, etc. | |
34 | |
35 - Level: Major | |
36 - Date range method `duration` is deprecated in favor of `span`. Additionally
it will add 1 to the duration to include the starting number itself. In effect f
or date ranges this means that `duration` will be 1 ms longer. | |
37 | |
38 - Level: Major | |
39 - `Range#step` alias was removed. Use `Range#every` instead. | |
40 | |
41 - Level: Major | |
42 - Date formatting tokens `z` and `zz` are now `Z` and `ZZ`. Additionally `zzz`
was removed. | |
43 | |
44 - Level: Moderate | |
45 - `Array#find` now works according to the ES6 spec. This means that it will no
longer take a `fromIndex` or `loop` arguments. Instead, the second argument is
the context in which the function matcher will be run. If you need the previous
functionality, use `Array#findFrom` and `Array#findIndexFrom` instead. | |
46 | |
47 - Level: Moderate | |
48 - `Array.sortBy` now performs a natural sort by default. This means numbers (a
ny consecutive numbers, so this will include currency formatting, etc.) will sor
t as numbers, (2 before 100). If you do not want this behavior, set the flag `Ar
ray.AlphanumericSortNatural` to `false`. | |
49 | |
50 - Level: Moderate | |
51 - `Object.clone` now will error if being called on a user-created class instan
ce or host object (DOM Elements, Events, etc). A number of complex issues tie in
here, but in the end it is unreliable to call `clone` on an object that is not
a standard data types as 1) hidden properties cannot be cloned 2) the original a
rguments to the constructor cannot be known 3) even if they could be known the i
ssue of whether or not the constructor should actually be called again is not cl
ear. | |
52 | |
53 - Level: Moderate | |
54 - The `split` argument was removed from `String#truncate`. For truncating with
out splitting words, use `String#truncateOnWord` instead. Argument position is a
djusted accordingly. | |
55 | |
56 - Level: Moderate | |
57 - Class instances are now internally matched by reference only. This means tha
t `Object.equal(new Person, new Person)` will now be `false`. This was in fact t
he original intended behavior but a bug had not been closed here leading to it n
ot actually being `false`. Although a case can be made for matching class instan
ces by value, in the end it is too expensive and tricky to distinguish them from
host objects, which should never be matched by value. Instead it is better to c
heck for equality of class instances on a unique identifier or the like. | |
58 | |
59 - Level: Moderate | |
60 - `Object.isObject` will now no longer return true for class instances for the
same reasons listed above. This also was intended behavior but was defective. | |
61 | |
62 - Level: Moderate | |
63 - `String#normalize` is now deprecated, but still available as a separate scri
pt in the `lib/plugins` directory. | |
64 | |
65 - Level: Moderate | |
66 - Date ranges are now their own package (the "range" package), are not depende
nt on the Date package, and work on numbers and strings as well. | |
67 | |
68 - Level: Minor | |
69 - Enumerable methods on object will now coerce primitive types. This means tha
t `Object.findAll('foo')` will now treat `'foo'` as `new String('foo')`. This is
reversed from the previous behavior which would error on primitive types and co
erce objects to primitive types where possible. | |
70 | |
71 - Level: Minor | |
72 - `String#capitalize` passing the `all` flag now will not capitalize after an
apostrophe. | |
73 | |
74 - Level: Very Minor | |
75 - Date ranges that have an end that is less than the start are now no longer c
onsidered invalid, and can be iterated across in exactly the same manner. This m
eans that ranges can now be iterated in reverse and .start and .end are no longe
r equivalent to .min and .max. | |
76 | |
77 - Level: Very Minor | |
78 - Removed `Number#upto` and `Number#downto` will now work on inverse ranges. I
n other words (1).downto(5) if represented as an array will now produce [1,2,3,4
,5] even though 1 is less than 5 and the operator was "downto". It will also ste
p through the range accordingly. | |
79 | |
80 - Level: Very Minor | |
81 - Passing a regex to array matching methods like `findAll` will now match it d
irectly against the element in the array, regardless of whether or not the match
ed element is a string or not. This makes the logic more straightforward but it
also means that it will stringify the element before attempting to match. If, fo
r example, you have instances of classes in the array and the regex is /t/, the
/t/ will return true for that element as it will match the stringified "[object
Object]" of the instance, which is likely not what you want, so caution is neede
d here. | |
82 | |
83 - Level: Very Minor | |
84 - Passing `null` to `.map` will now have the same effect as `undefined` (or no
arguments), that is, no mapping will occur. This will apply to any method makin
g use of the internal `transformArgument`, so `Array#min`, `Array#max`, and `Arr
ay#groupBy` are affected as well. | |
85 | |
86 - Level: Very Minor | |
87 - `String#pad/padLeft/padRight` will now raise an error on padding to a negati
ve number. Conversely, they will no longer raise an error on undefined/null/NaN. | |
88 | |
89 | |
90 v1.3.9+ | |
91 ======= | |
92 | |
93 - Level: Major | |
94 - Removed `String#namespace`. | |
95 | |
96 | |
97 v1.3.8+ | |
98 ======= | |
99 | |
100 - Level: Major | |
101 - Renamed `Date#getWeek` and `Date#setWeek` to `Date#getISOWeek` and `Date#set
ISOWeek`. | |
102 | |
103 - Level: Very Minor | |
104 - Object.clone will now preserve a date's internal utc flag when set. | |
105 | |
106 | |
107 v1.3.7+ | |
108 ======= | |
109 | |
110 - Level: Major | |
111 - `String#startsWith` and `String#endsWith` now accept different arguments to
better align them with the Harmony proposal of the same name. The second argumen
t is now the "position" that limits where the string starts/ends, and the "case"
flag indicating case sensitivity is now pushed to the 3rd argument. | |
112 | |
113 - Level: Major | |
114 - Enumerable object methods are now included when using `Object.extend()` maki
ng it that much more dangerous, especially as generic methods like `count` are n
ow defined on the Object prototype. If you use this method, make sure you are in
the habit of using `hasOwnProperty` when checking for presence inside a hash (p
robably not a bad idea anyway). Also note that Sugar itself has a number of area
s that may exhibit unexpected behavior when this method is applied. Please repor
t if you find any. | |
115 | |
116 - Level: Moderate | |
117 - Aliases on dates such as `daysAgo` will now count "past" an integer instead
of rounding. This means that `Date.create('23 hours ago').daysAgo()` will now be
`0`. There is however a small margin of error (roughly 0.1%) that will trigger
a round up, which is higher for months, which have a more vague definition and a
higher margin for error. | |
118 | |
119 | |
120 v1.3.6+ | |
121 ======= | |
122 | |
123 - Level: Very Minor | |
124 - Float values should be properly parsed in `Object.fromQueryString`, meaning
IP addresses and the like will now parse as strings instead of truncated numbers
. | |
125 | |
126 - Level: Very Minor | |
127 - NaN is no longer true for `isOdd`. | |
128 | |
129 - Level: Very Minor | |
130 - Date parsing now only allows a maximum of 59 for minutes and seconds. | |
131 | |
132 | |
133 v1.3.5+ | |
134 ======= | |
135 | |
136 - Level: Very Minor | |
137 - `Array.create` now properly creates arrays from objects. | |
138 | |
139 | |
140 v1.3.2+ | |
141 ======= | |
142 | |
143 - Level: Minor | |
144 - `Date.create` will no longer set the UTC flag on dates created from an ISO s
tring with the "Z" flag. This can be considered a bug introduced in the last rel
ease. The "Z" flag indicates that a date is in UTC time, but should not serve as
an indication that the date should further be manipulated as UTC, only as a cue
when parsing. If you want the date to actually behave as UTC (internally call U
TC methods), then you need to explicitly set with `Date#utc(true)` now. | |
145 | |
146 | |
147 v1.3.1+ | |
148 ======= | |
149 | |
150 | |
151 - Level: Major | |
152 - Array methods that allow fuzzy matching on an object (`findAll`, `filter`, `
some`, etc.) as well as `unique`, `intersect`, `union`, and `subtract`, will now
match by reference unless certain conditions are met. Most notably this means t
hat arrays of functions as well as arrays of host objects (DOM elements, etc.) w
ill now only match elements that are strictly true by reference (`===`). If you
are using arrays of host objects or functions (event handlers and the like), use
caution upgrading. Other kinds of arrays such as primitives (strings, numbers,
etc) as well as object literals and instances of user-defined objects should not
be affected. | |
153 | |
154 - Level: Major | |
155 - `Date#toUTC` deprecated. Previously, this method would subtract the timezone
offset of the date, providing a pseudo-utc date. This was a very primitive way
of handling the challenge of manipulating utc dates and had drawbacks such as su
bsequent date manipulations resetting to a localized time. This is now deprecate
d in favor of `Date#utc`, which simply sets an internal flag that will tell Suga
r to use utc-based date methods or not. `Date#utc` will NOT manipulate the time
in any way. To create a utc-based date that is set to utc time, a flag has been
added to `Date#create`, and other creation methods like `Date#future` and `Date#
past` to set the utc flag before parsing out the date. | |
156 | |
157 - Level: Major | |
158 - `Date#setUTC` deprecated. Instead, simply set the utc flag using `Date#utc`
or passing `true` as the third argument to `Date#create`. After this point, utc-
based methods will be used internally, making this method unnecessary. | |
159 | |
160 - Level: Major | |
161 - `Date#setUTCWeek` deprecated. Set the utc flag and use `Date#setWeek` instea
d. | |
162 | |
163 - Level: Major | |
164 - `Date#getUTCWeek` deprecated. Set the utc flag and use `Date#getWeek` instea
d. | |
165 | |
166 - Level: Major | |
167 - `Date#setUTCWeekday` deprecated. Set the utc flag and use `Date#setWeekday`
instead. | |
168 | |
169 - Level: Minor | |
170 - `Date#clone` will now preserve the utc flag. | |
171 | |
172 - Level: Minor | |
173 - Array methods matching an empty object `{}` will now return true instead of
false against another empty object. | |
174 | |
175 - Level: Very Minor | |
176 - `Date#setWeekday` now returns a timestamp instead of `undefined`. | |
177 | |
178 | |
179 v1.3+ | |
180 ======= | |
181 | |
182 | |
183 - Level: Major | |
184 - Date locales are now moved into a separate package. This means that now with
the default download package, setting the date locale to anything other than En
glish will throw an error. If you require locales other than English, please inc
lude them from [the customize page](http://sugarjs.com/customize). | |
185 | |
186 - Level: Major | |
187 - `Array#min`, `Array#max`, `Array#least`, and `Array#most` now return a singl
e value instead of an array. If you need to get "all min" or "all max" values, t
hen pass `true` as the second argument to these methods. | |
188 | |
189 - Level: Major | |
190 - `Array#has` is deprecated. Use `Array#some` or `Array#any` instead. | |
191 | |
192 - Level: Major | |
193 - `String#toDate` is deprecated. Use `Date.create` instead. | |
194 | |
195 - Level: Major | |
196 - `String#add`, `String#insert`, `Array#add`, and `Array#insert` now consider
negative indexes to be the same as built-in `Array#slice`. This means that addin
g 'd' to 'abc' at index -1 now results in 'abdc' instead of 'abcd'. | |
197 | |
198 - Level: Major | |
199 - Date parsing is now scoped by locale. Previously setting a locale would add
all its formats into a common pool that would match from that point on. Now the
locale must be either be set beforehand `Date.setLocale('fr')` or explicitly pas
sed `Date.create('...', 'fr')`. The exception to this are numeric formats which
are core formats and will parse in any locale. | |
200 | |
201 - Level: Minor | |
202 - Extended objects that are otherwise identical to non-extended counterparts a
re now considered equal by `Object.equal`. | |
203 | |
204 - Level: Minor | |
205 - `Object.isEmpty` will now error when passed a non-object. This includes obje
ct versions of primitives like strings, numbers, and booleans. | |
206 | |
207 - Level: Minor | |
208 - Default date output format `date.format()` now includes the time. Previously
this was just the date. | |
209 | |
210 - Level: Minor | |
211 - `Array#groupBy` no longer returns extended objects. Use `Object.extended` on
the result if you need this. | |
212 | |
213 - Level: Minor | |
214 - Unrecognized locale codes will now simply produce an invalid date instead of
throwing an error. Likewise, fully qualified locale codes ('it_IT') will fall b
ack to 2 character codes ('it') before giving up. | |
215 | |
216 - Level: Very Minor | |
217 - Array methods using fuzzy matching (findAll, remove, etc.) now match instanc
es of classes as well as plain objects. | |
218 | |
219 - Level: Very Minor | |
220 - `String#capitalize` with the first argument as `true` (capitalize all words)
will now capitalize any letter whose previous letter could not be capitalized.
Previously only words after spaces were counted. | |
221 | |
222 | |
223 | |
224 v1.2.5+ | |
225 ======= | |
226 | |
227 - Level: Major | |
228 - `String#truncate` arguments changed. `ellipsis` (`"..."` by default) is now
the last argument of four. Second argument is now `split` which is true by defau
lt, so the method will behave like standard truncate methods by default. `from`
added as the third parameter and determines where to truncate. Can be `"right"`
(default), `"left"`, or `"middle"`. | |
229 | |
230 - Level: Major | |
231 - `Function#debounce` no longer has an argument `wait`. Equivalent function is
now `Function#throttle` (no arguments). `fn.debounce(100, false)` is now `fn.th
rottle(100)`. | |
232 | |
233 - Level: Minor | |
234 - `Object.isObject` now returns `true` for extended objects. | |
235 | |
236 | |
237 v1.2.4+ | |
238 ======= | |
239 | |
240 - Level: Minor | |
241 - Object.equal and its instance method form "equals" is now considered "egal".
This means that, for example, new String('w') will NOT be equal to 'w', etc. Pr
eviously equal was nearly egal, but not quite, so this should only affect very s
mall edge cases. This now means that Sugar will match Underscore's _.isEqual met
hod 100% of the time with the only exception being custom "isEqual" methods that
Underscore checks explicitly. | |
242 | |
243 - Level: Very Minor | |
244 - Object.merge will now merge properties of non-objects like functions. | |
245 | |
246 | |
247 | |
248 v1.2.3+ | |
249 ======= | |
250 | |
251 - Level: Major | |
252 - String#compare, Number#compare, and Date#compare are deprecated | |
253 | |
254 - Level: Major | |
255 - Object.merge params are swapped. `resolve` is now the 4th parameter and `dee
p` is now 3rd. | |
256 - When using extended objects, this are now 2nd and 3rd parameters. `deep` is
now false by default. | |
257 | |
258 - Level: Minor | |
259 - Array#sortBy now exhibits more sensible behavior when sorting on strings. | |
260 | |
261 | |
262 | |
263 v1.2.2+ | |
264 ======= | |
265 | |
266 - Level: Very Minor | |
267 - Extended objects now keep their "Hash" constructor (which is internal) so th
ey no longer have `Object` as their constructor. If you are doing instanceof che
cks here this may break (which you shouldn't be doing anyway) | |
268 | |
269 | |
270 | |
271 v1.2+ | |
272 ===== | |
273 | |
274 - Level: Major | |
275 - Array methods now use "fuzzy object matching" when passing an object. As an
example, `arr.find({ foo: 'bar' })` would previously only match an identical obj
ect, now it will match any object whose `foo` property is `bar`. Additionally, n
ote that passing regexes and functions will be used to match (regexes match agai
nst strings, functions are callbacks that return `true`/`false`), not compared d
irectly. This applies to the following array methods: `every`, `some`, `filter`,
`find`, `findAll`, `findIndex`, `remove`, `none`, `count`, and `exclude`. | |
276 | |
277 - Level: Major | |
278 - Object.sugar renamed to Object.restore. However Object.sugar() equivalent is
now Object.extend(). | |
279 | |
280 - Level: Minor | |
281 - Object.merge now also merges undefined properties. | |
282 | |
283 | |
284 | |
285 v1.1.2+ | |
286 ======= | |
287 | |
288 - Level: Minor | |
289 - Function#after will now call a method immediately if the passed value is `0`
. | |
290 | |
291 - Level: Very minor | |
292 - Object.isEmpty will now properly report `false` for primitive types like `nu
ll` and empty strings. | |
293 | |
294 | |
295 | |
296 v1.1.1+ | |
297 ======= | |
298 | |
299 - Level: Major | |
300 - Object.merge no longer merges an arbitrary number of arguments. Use extended
objects and chaining instead. | |
301 | |
302 - Level: Minor | |
303 - Array#remove and Array#exclude now no longer accept an arbitrary number of a
rguments. Pass only 1 argument to these methods (may be a nested array). | |
304 | |
305 | |
306 | |
307 v1.1+ | |
308 ===== | |
309 | |
310 - Level: Major | |
311 - Object.equals renamed to Object.equal. | |
312 | |
313 - Level: Major | |
314 - Number#format "thousands" and "decimal" parameters are now pushed to the 2nd
and 3rd parameters, adding a "place" for the decimal as the 1st. | |
315 | |
316 - Level: Minor | |
317 - A few tokens were removed from Date#format. See sugarjs.com/dates for a list
of currently accepted tokens. | |
318 | |
319 - Level: Minor | |
320 - Function#lazy now executes, then waits as opposed to waiting, then executing
. | |
321 | |
322 - Level: Minor | |
323 - Array#sortBy is now no longer destructive, so you will need to set the varia
ble explicitly. | |
324 | |
325 | |
326 | |
327 v1.0+ | |
328 ===== | |
329 | |
330 | |
331 - Level: Major | |
332 - String#normalize is removed, but now available in the Inflections module, av
ailable at sugarjs.com/customize. | |
333 | |
334 - Level: Major | |
335 - String#is/hasArmenian, is/hasBopomofo, is/hasEthiopic, and is/hasGeorgian de
precated. | |
336 | |
337 - Level: Minor | |
338 - Passing a second parameter to Date#set now no longer resets only the time, b
ut also any unit less specific than the most specific one set. So if the object
`{ hours: 5 }` is passed with the second parameter `true`, minutes, seconds, and
milliseconds will be reset. | |
339 | |
340 - Level: Minor | |
341 - Passing "relative" as the format to Date#format is now deprecated, and inste
ad Date#relative. | |
342 | |
343 - Level: Minor | |
344 - Date.allowVariant deprecated in favor of the locale system. Any locale that
is not 'en' or 'en-US' will use variants when ambiguities exist. | |
345 | |
346 - Level: Very minor | |
347 - Date#format token suffixes " short", and " pad" deprecated. | |
348 | |
349 - Level: Very minor | |
350 - When passing a function to Date#format or Date#relative, the "dir" parameter
is now deprecated. Instead the milliseconds argument has a sign directly on it. | |
351 | |
352 | |
353 | |
354 v0.9.5+ | |
355 ======= | |
356 | |
357 | |
358 - Level: Major | |
359 - Array#split deprecated. | |
360 | |
361 - Level: Major | |
362 - String#toObject is now Object.fromQueryString. | |
363 | |
364 - Level: Major | |
365 - Function.lazy is now Function#lazy and is called directly on function instan
ces. | |
366 | |
367 - Level: Major | |
368 - Function#defer is now simply Function#delay with no arguments. | |
369 | |
370 - Level: Moderate | |
371 - Object.clone is now shallow by default. | |
372 | |
373 | |
374 | |
375 v0.9.3+ | |
376 ======= | |
377 | |
378 | |
379 - Level: Major | |
380 - Array#each is no longer an alias of Array#forEach and now has its own behavi
or including a 2nd parameter for the start index, 3rd parameter for looping from
the beginning, returning the array, allowing returning false to break the loop,
passing the array as scope to the callback, and support for sparse arrays. | |
381 | |
382 - Level: Major | |
383 - Array#eachFromIndex deprecated. | |
384 | |
385 - Level: Major | |
386 - Array#removeAtIndex renamed to Array#removeAt. | |
387 | |
388 - Level: Major | |
389 - Array#collect deprecated. | |
390 | |
391 - Level: Major | |
392 - Array#shuffle deprecated. | |
393 | |
394 - Level: Major | |
395 - String#titleize deprecated. It is now available again as of v1.2 in the Infl
ections module, available at sugarjs.com/customize. | |
396 | |
397 - Level: Major | |
398 - String#pad/padLeft/padRight changed argument order to padding first and numb
er second. | |
399 | |
400 - Level: Moderate | |
401 - Array#indexOf/lastIndexOf now performs a simple `===` equality check instead
of a deep recursive property check. | |
402 | |
403 - Level: Minor | |
404 - String#repeat will now return a blank string on numbers less than 1. | |
405 | |
406 - Level: Minor | |
407 - String#dasherize and String#underscore now strip whitespace. | |
408 | |
409 | |
410 | |
411 v0.9.1+ | |
412 ======= | |
413 | |
414 - Level: Major | |
415 - Object.create changed to Object.extended. | |
416 | |
417 | |
OLD | NEW |