Bug 1188613 - Handle attribute mutations with null value. r=pbrosset a=ritu
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 12 Aug 2015 08:38:31 -0500
changeset 288799 865e3879982dce9bb015cfd28fb5d00a8d3cd2f6
parent 288798 733f333f82c2e5f0e30c81620daf1c8d7b92c9ae
child 288800 aea52aa8c59acb5b63c27961d5e44029c11f301d
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbrosset, ritu
bugs1188613
milestone42.0a2
Bug 1188613 - Handle attribute mutations with null value. r=pbrosset a=ritu
browser/devtools/markupview/markup-view.js
--- a/browser/devtools/markupview/markup-view.js
+++ b/browser/devtools/markupview/markup-view.js
@@ -2733,21 +2733,20 @@ ElementEditor.prototype = {
     let attributes = this.node.attributes.filter(({name}) => name !== aAttr.name);
     attributes.push(aAttr);
     let parsedLinksData = parseAttribute(this.node.namespaceURI,
       this.node.tagName, attributes, aAttr.name);
 
     // Create links in the attribute value, and collapse long attributes if
     // needed.
     let collapse = value => {
-      if (value.match(COLLAPSE_DATA_URL_REGEX)) {
+      if (value && value.match(COLLAPSE_DATA_URL_REGEX)) {
         return truncateString(value, COLLAPSE_DATA_URL_LENGTH);
-      } else {
-        return truncateString(value, COLLAPSE_ATTRIBUTE_LENGTH);
       }
+      return truncateString(value, COLLAPSE_ATTRIBUTE_LENGTH);
     };
 
     val.innerHTML = "";
     for (let token of parsedLinksData) {
       if (token.type === "string") {
         val.appendChild(this.doc.createTextNode(collapse(token.value)));
       } else {
         let link = this.doc.createElement("span");
@@ -2915,17 +2914,17 @@ ElementEditor.prototype = {
 };
 
 function nodeDocument(node) {
   return node.ownerDocument ||
     (node.nodeType == Ci.nsIDOMNode.DOCUMENT_NODE ? node : null);
 }
 
 function truncateString(str, maxLength) {
-  if (str.length <= maxLength) {
+  if (!str || str.length <= maxLength) {
     return str;
   }
 
   return str.substring(0, Math.ceil(maxLength / 2)) +
          "…" +
          str.substring(str.length - Math.floor(maxLength / 2));
 }