mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-14 22:56:19 +01:00
WP-API: JavaScript client - fix setup of models used by wp.api.collections objects.
Correct setup for the `model` attribute of `wp.api.collections` objects. Set the collection model as a function that returns a new model of the underlying type, instead of setting it as the model prototype. Fixes an issue where models for fetched collections weren't set up properly and didn't have the expected mixin methods such as `getCategories` available. Props jesseenterprises. Merges [39603] to the 4.7 branch. Fixes #39070. Built from https://develop.svn.wordpress.org/branches/4.7@39604 git-svn-id: http://core.svn.wordpress.org/branches/4.7@39544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
948379bde8
commit
6bfa2de24d
@ -1234,7 +1234,9 @@
|
||||
},
|
||||
|
||||
// Specify the model that this collection contains.
|
||||
model: loadingObjects.models[ modelClassName ],
|
||||
model: function( attrs, options ) {
|
||||
return new loadingObjects.models[ modelClassName ]( attrs, options );
|
||||
},
|
||||
|
||||
// Include a reference to the original class name.
|
||||
name: collectionClassName,
|
||||
@ -1257,7 +1259,9 @@
|
||||
url: routeModel.get( 'apiRoot' ) + routeModel.get( 'versionString' ) + routeName,
|
||||
|
||||
// Specify the model that this collection contains.
|
||||
model: loadingObjects.models[ modelClassName ],
|
||||
model: function( attrs, options ) {
|
||||
return new loadingObjects.models[ modelClassName ]( attrs, options );
|
||||
},
|
||||
|
||||
// Include a reference to the original class name.
|
||||
name: collectionClassName,
|
||||
|
2
wp-includes/js/wp-api.min.js
vendored
2
wp-includes/js/wp-api.min.js
vendored
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7.1-alpha-39602';
|
||||
$wp_version = '4.7.1-alpha-39604';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user