[Pkg-mozext-commits] [firebug] 35/82: Don't output attributes with undefined values in domplate

David Prévot taffit at moszumanska.debian.org
Mon Mar 31 22:45:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag fbtest-1.11.2
in repository firebug.

commit 30f349a39dd803e5cc90c8103782e15ca1263dc8
Author: Simon Lindholm <simon.lindholm10 at gmail.com>
Date:   Mon Dec 31 22:53:24 2012 +0100

    Don't output attributes with undefined values in domplate
---
 extension/content/firebug/lib/domplate.js | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/extension/content/firebug/lib/domplate.js b/extension/content/firebug/lib/domplate.js
index d85e321..bd19e29 100644
--- a/extension/content/firebug/lib/domplate.js
+++ b/extension/content/firebug/lib/domplate.js
@@ -134,7 +134,7 @@ DomplateTag.prototype =
             var val = parseValue(args[name]);
             readPartNames(val, this.vars);
 
-            if (Str.hasPrefix(name, "on"))
+            if (name.lastIndexOf("on", 0) == 0)
             {
                 var eventName = name.substr(2);
                 if (!this.listeners)
@@ -230,6 +230,16 @@ DomplateTag.prototype =
             return Str.escapeForElementAttribute(value);
         }
 
+        function __attr__(name, valueParts)
+        {
+            // Will be called with valueParts = [,arg,arg,...], but we don't
+            // care that the first element is undefined.
+            if (valueParts.length === 2 && valueParts[1] === undefined)
+                return "";
+            var value = valueParts.join("");
+            return ' ' + name + '="' + __escape__(value) + '"';
+        }
+
         function isArray(it)
         {
             return Object.prototype.toString.call(it) === "[object Array]";
@@ -318,12 +328,11 @@ DomplateTag.prototype =
             if (name != "class")
             {
                 var val = this.attrs[name];
-                topBlock.push(', " ', name, '=\\""');
-                addParts(val, ',', topBlock, info, true);
-                topBlock.push(', "\\""');
+                topBlock.push(',__attr__("', name, '",[');
+                addParts(val, ',', topBlock, info, false);
+                topBlock.push('])');
             }
         }
-
         if (this.listeners)
         {
             for (var i = 0; i < this.listeners.length; i += 2)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firebug.git



More information about the Pkg-mozext-commits mailing list