diff --git a/core/modules/contextual/js/contextual.es6.js b/core/modules/contextual/js/contextual.es6.js index e231e80b95..8c2b1aed40 100644 --- a/core/modules/contextual/js/contextual.es6.js +++ b/core/modules/contextual/js/contextual.es6.js @@ -105,7 +105,7 @@ .find('.contextual'); // Early-return when there's no nesting. - if ($contextuals.length === 1) { + if ($contextuals.length <= 1) { return; } diff --git a/core/modules/contextual/js/contextual.js b/core/modules/contextual/js/contextual.js index 39daa09973..a23ac66ab3 100644 --- a/core/modules/contextual/js/contextual.js +++ b/core/modules/contextual/js/contextual.js @@ -64,7 +64,7 @@ function adjustIfNestedAndOverlapping($contextual) { var $contextuals = $contextual.parents('.contextual-region').eq(-1).find('.contextual'); - if ($contextuals.length === 1) { + if ($contextuals.length <= 1) { return; } diff --git a/core/modules/quickedit/js/quickedit.es6.js b/core/modules/quickedit/js/quickedit.es6.js index 3fe50076a2..c5c162d449 100644 --- a/core/modules/quickedit/js/quickedit.es6.js +++ b/core/modules/quickedit/js/quickedit.es6.js @@ -359,7 +359,15 @@ // [data-quickedit-entity-id] element's data-quickedit-entity-instance-id // attribute. const entityElementSelector = `[data-quickedit-entity-id="${entityID}"]`; - let entityElement = $(fieldElement).closest(entityElementSelector); + const $entityElement = $(fieldElement).closest(entityElementSelector); + + // If there are no elements returned from `entityElementSelector` + // throw an error. Check the browser console for this message. + if (!$entityElement.length) { + throw `Quick Edit could not associate the rendered entity field markup (with [data-quickedit-field-id="${fieldID}"]) with the corresponding rendered entity markup: no parent DOM node found with [data-quickedit-entity-id="${entityID}"]. This is typically caused by the theme's template for this entity type forgetting to print the attributes.`; + } + let entityElement = $(fieldElement).closest($entityElement); + // In the case of a full entity view page, the entity title is rendered // outside of "the entity DOM node": it's rendered as the page title. So in // this case, we find the lowest common parent element (deepest in the tree) diff --git a/core/modules/quickedit/js/quickedit.js b/core/modules/quickedit/js/quickedit.js index f1e2431fda..e4c168970d 100644 --- a/core/modules/quickedit/js/quickedit.js +++ b/core/modules/quickedit/js/quickedit.js @@ -159,7 +159,12 @@ var entityID = extractEntityID(fieldID); var entityElementSelector = '[data-quickedit-entity-id="' + entityID + '"]'; - var entityElement = $(fieldElement).closest(entityElementSelector); + var $entityElement = $(fieldElement).closest(entityElementSelector); + + if (!$entityElement.length) { + throw 'Quick Edit could not associate the rendered entity field markup (with [data-quickedit-field-id="' + fieldID + '"]) with the corresponding rendered entity markup: no parent DOM node found with [data-quickedit-entity-id="' + entityID + '"]. This is typically caused by the theme\'s template for this entity type forgetting to print the attributes.'; + } + var entityElement = $(fieldElement).closest($entityElement); if (entityElement.length === 0) { var $lowestCommonParent = $(entityElementSelector).parents().has(fieldElement).first();