#26799 closed enhancement (fixed)
Update to Backbone.js 1.1.0
Reported by: | ericlewis | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | External Libraries | Keywords: | has-patch |
Focuses: | Cc: |
Description
Backbone.js 1.1.0 was released in Oct 10, 2013.
Attachments (5)
Change History (22)
#2
@
11 years ago
- Component changed from General to External Libraries
- Type changed from defect (bug) to enhancement
#3
@
11 years ago
- Keywords has-patch added
I took a look at this and was able to put together an initial patch.
For reference, here are the changes between 1.0 and 1.1:
- Made the return values of Collection’s set, add, remove, and reset more useful. Instead of returning this, they now return the changed (added, removed or updated) model or list of models.
- Backbone Views no longer automatically attach options passed to the constructor as this.options and Backbone Models no longer attach url and urlRoot options, but you can do it yourself if you prefer.
- All “invalid” events now pass consistent arguments. First the model in question, then the error object, then options.
- You are no longer permitted to change the id of your model during parse. Use idAttribute instead.
- On the other hand, parse is now an excellent place to extract and vivify incoming nested JSON into associated submodels.
- Many tweaks, optimizations and bugfixes relating to Backbone 1.0, including URL overrides, mutation of options, bulk ordering, trailing slashes, edge-case listener leaks, nested model parsing…
The attachment:26799-02.patch (the two earlier patches were false starts) includes:
- Upgrades Backbone to 1.1 and Underscore to 1.5.2
- Switches to un-minified versions of both for development. (It would be nice if we could do this for all of the third-party libraries even if it means coming up with some sort of constant that is used when running from a checkout of develop.svn.wordpress.org to minimize the impact on package size)
- Adjustments needed to deal with issues that arose due to the first two items in the above change log.
#4
@
11 years ago
I worry about updating a library that contains backwards incompatible changes. We've avoided updating Masonry in the past due to the this. Updating our libraries with backwards incompatible changes has a decent change to break plugins and themes and is something we should avoid doing.
I think we either need to create a wrapper or work with the upstream libraries to ensure they maintain backwards compatibility.
#5
@
11 years ago
I understand your point of view and think that it would be worthwhile for someone to open a dialog with Jeremy or one of the other Backbone leads. Since version 1.1 has already been released, I think we shouldn't delay updating because the delay will mean that plugin authors writing new code may write in a style that is only compatible with older versions of Backbone. The good news is that if plugin authors are taking advantage of wp.Backbone.View
, the change to no longer automatically attach this.options
won't cause problems. We could consider adding wrappers for Backbone.Model
and Backbone.Collection
to provide us with a way to try and avoid backwards-compatibility issues, but that won't help Backbone code that has already been written.
We also could explore using wp.Backbone = Backbone.noConflict()
so that it is easier for plugin authors to supply their own version of Backbone should they choose.
This ticket was mentioned in IRC in #wordpress-dev by gcorne. View the logs.
11 years ago
#8
@
11 years ago
Added a refreshed patch as attachment:26799-03.patch.
This ticket was mentioned in IRC in #wordpress-dev by georgestephanis. View the logs.
11 years ago
#11
follow-up:
↓ 13
@
11 years ago
@gcorne -- it looked like you had added the uncompressed backbone and removed the min version in your previous patch, so I duplicated that for underscore. Unsure if we should just use their versions either with or without the .min.map -- I left it off, as that seemed to be where we were going after the jQuery discussion and r25072
This ticket was mentioned in IRC in #wordpress-dev by DH-Shredder. View the logs.
11 years ago
#13
in reply to:
↑ 11
;
follow-up:
↓ 14
@
11 years ago
Replying to georgestephanis:
@gcorne -- it looked like you had added the uncompressed backbone and removed the min version in your previous patch, so I duplicated that for underscore.
My thought was that we would rely on the build process grunt build
to create the minified versions. Whether or not we actually ship with both compressed and uncompressed versions is up for discussion, but personally I find having the uncompressed versions super helpful during development.
#14
in reply to:
↑ 13
@
11 years ago
Per IRC: We're doing this.
Replying to gcorne:
My thought was that we would rely on the build process
grunt build
to create the minified versions.
We usually prefer to use a library's official minified version, rather than our own. But I have an idea here.
I accidentally started working with 1.1.0 today, and came across an issue with the WP Media experience.
I tried basic boilerplate for creating a media modal that didn't work.
Error I got:
Uncaught TypeError: Cannot read property 'states' of undefined
inmedia.view.Frame._createStates()
I assume the issue is this: