Filters enabled view modes to assure they are registered.
This commit is contained in:
parent
94875d050b
commit
5a5f40c6c9
|
@ -81,9 +81,13 @@ export default (element) => {
|
||||||
|
|
||||||
// At first, we consider that all registered view modes are included.
|
// At first, we consider that all registered view modes are included.
|
||||||
let possibleViewModes = registeredViewModes;
|
let possibleViewModes = registeredViewModes;
|
||||||
if ( getDataAttribute(blockElement, 'enabled-view-modes') != undefined )
|
if ( getDataAttribute(blockElement, 'enabled-view-modes') != undefined ) {
|
||||||
possibleViewModes = getDataAttribute(blockElement, 'enabled-view-modes').split(',');
|
possibleViewModes = getDataAttribute(blockElement, 'enabled-view-modes').split(',');
|
||||||
|
|
||||||
|
// Filter out the view modes that are not registered
|
||||||
|
possibleViewModes = possibleViewModes.filter(viewModeSlug => registeredViewModes.indexOf(viewModeSlug) >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
// View Mode settings
|
// View Mode settings
|
||||||
let possibleDefaultViewMode = 'masonry';
|
let possibleDefaultViewMode = 'masonry';
|
||||||
if ( getDataAttribute(blockElement, 'default-view-mode') != undefined )
|
if ( getDataAttribute(blockElement, 'default-view-mode') != undefined )
|
||||||
|
|
Loading…
Reference in New Issue