Bug 1354211 - Consider <optgroup> when finding container element. r?automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Sun, 31 Dec 2017 14:32:38 +0000
changeset 719569 53070397813ec6b1a71d304033edc460fbccf765
parent 719367 f7f5ba2214d2ce7b1ce9647b0e2540490a6098a8
child 719570 74258eee3a9e229b4bf29928389241a0b3ad064d
push id95293
push userbmo:ato@sny.no
push dateFri, 12 Jan 2018 10:32:36 +0000
reviewersautomatedtester
bugs1354211
milestone59.0a1
Bug 1354211 - Consider <optgroup> when finding container element. r?automatedtester It is a bug in element.getContainer that <optgroup> is not considered when locating the containing context element, <select>. <optgroup> is also a child element of <select> on the same level as <option>. MozReview-Commit-ID: 2GJJrRuY5Th
testing/marionette/element.js
--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -842,35 +842,33 @@ element.inViewport = function(el, x = un
  *
  * If the element does not have a valid context, its container element
  * is itself.
  *
  * @param {Element} el
  *     Element to get the container of.
  *
  * @return {Element}
- *     Container element of |el|.
+ *     Container element of <var>el</var>.
  */
 element.getContainer = function(el) {
-
   function findAncestralElement(startNode, validAncestors) {
     let node = startNode;
     while (node.parentNode) {
       node = node.parentNode;
       if (validAncestors.includes(node.localName)) {
         return node;
       }
     }
-
     return startNode;
   }
 
-  // Does <option> have a valid context,
+  // Does <option> or <optgroup> have a valid context,
   // meaning is it a child of <datalist> or <select>?
-  if (el.localName === "option") {
+  if (["option", "optgroup"].includes(el.localName)) {
     return findAncestralElement(el, ["datalist", "select"]);
   }
 
   // Child nodes of button will not be part of the element tree for
   // elementsFromPoint until bug 1089326 is fixed.
   return findAncestralElement(el, ["button"]);
 };