Bug 1363053 - Use Node.ELEMENT_NODE instead of magic number draft
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 08 May 2017 18:58:47 +0100
changeset 576903 a5f4bf766daf370eeb7acc7307d0f404f273a5f9
parent 576902 bd4b73344eea7393d0018397ecce04da4dbbd6e6
child 628342 fe3dc66ef0ca802920212ec0b51f85a670d033c0
push id58516
push userbmo:ato@mozilla.com
push dateFri, 12 May 2017 13:17:18 +0000
bugs1363053
milestone55.0a1
Bug 1363053 - Use Node.ELEMENT_NODE instead of magic number This patch removes the magic number and instead uses the ELEMENT_NODE constant which exists on all objects of the Node prototype chain. We already test that obj has a nodeType own property. MozReview-Commit-ID: If9HIkBjCyN
testing/marionette/evaluate.js
--- a/testing/marionette/evaluate.js
+++ b/testing/marionette/evaluate.js
@@ -260,17 +260,17 @@ evaluate.toJSON = function (obj, seenEls
   }
 
   // Array, NodeList, HTMLCollection, et al.
   else if (element.isCollection(obj)) {
     return [...obj].map(el => evaluate.toJSON(el, seenEls));
   }
 
   // HTMLElement
-  else if ("nodeType" in obj && obj.nodeType == 1) {
+  else if ("nodeType" in obj && obj.nodeType == obj.ELEMENT_NODE) {
     let uuid = seenEls.add(obj);
     return element.makeWebElement(uuid);
   }
 
   // custom JSON representation
   else if (typeof obj["toJSON"] == "function") {
     let unsafeJSON = obj.toJSON();
     return evaluate.toJSON(unsafeJSON, seenEls);