[Pkg-mozext-commits] [firebug] 64/82: Issue 6194: Clean up the DOMTokenList testing
David Prévot
taffit at moszumanska.debian.org
Mon Mar 31 22:45:41 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 a33026e4ef91fdf26b572cc6035523cc1c1487e8
Author: Simon Lindholm <simon.lindholm10 at gmail.com>
Date: Wed Jan 16 22:15:17 2013 +0100
Issue 6194: Clean up the DOMTokenList testing
http://code.google.com/p/fbug/issues/detail?id=6194
---
extension/content/firebug/chrome/reps.js | 55 ++++----------------------------
extension/content/firebug/lib/array.js | 21 +++++++++---
2 files changed, 23 insertions(+), 53 deletions(-)
diff --git a/extension/content/firebug/chrome/reps.js b/extension/content/firebug/chrome/reps.js
index 945b39e..58cbefd 100644
--- a/extension/content/firebug/chrome/reps.js
+++ b/extension/content/firebug/chrome/reps.js
@@ -793,62 +793,19 @@ FirebugReps.ArrayLikeObject = domplate(FirebugReps.ArrBase,
getTitle: function(obj, context)
{
- var arr = Wrapper.unwrapObject(obj);
- const re =/\[object ([^\]]*)/;
- var label = Str.safeToString(arr);
- var m = re.exec(label);
- if (m)
- return m[1] || label;
-
- if ((arr instanceof Ci.nsIDOMDOMTokenList) || (this.isTokenList_Fx19(obj)))
+ if (Arr._isDOMTokenList(obj))
return "DOMTokenList";
- return "";
+ const re = /\[object ([^\]]*)/;
+ var label = Object.prototype.toString.call(obj);
+ var m = re.exec(label);
+ return (m ? m[1] : label);
},
isArray: function(obj)
{
- if (this.isArrayLike_Fx19(obj))
- return true;
-
return Arr.isArrayLike(obj);
- },
-
- /**
- * Hack for Firefox 19 where obj instanceof Ci.nsIDOMDOMTokenList doesn't work.
- */
- isTokenList_Fx19: function(obj)
- {
- var context = Firebug.currentContext;
- if (!context)
- return false;
-
- var view = Wrapper.getContentView(context.window);
- if (!view)
- return false;
-
- obj = Wrapper.unwrapObject(obj);
- return (obj instanceof view.DOMTokenList);
- },
-
- /**
- * Hack for Firefox 19 where obj instanceof Ci.nsIDOMDOMTokenList,
- * Ci.nsIDOMHTMLCollection and nsIDOMNodeList doesn't work.
- */
- isArrayLike_Fx19: function(obj)
- {
- var context = Firebug.currentContext;
- if (!context)
- return false;
-
- var view = Wrapper.getContentView(context.window);
- if (!view)
- return false;
-
- obj = Wrapper.unwrapObject(obj);
- return (obj instanceof view.DOMTokenList) || (obj instanceof view.HTMLCollection) ||
- (obj instanceof view.NodeList);
- },
+ }
});
// ********************************************************************************************* //
diff --git a/extension/content/firebug/lib/array.js b/extension/content/firebug/lib/array.js
index 724683d..a24283c 100644
--- a/extension/content/firebug/lib/array.js
+++ b/extension/content/firebug/lib/array.js
@@ -9,6 +9,7 @@ function(FBTrace) {
// Constants
const Ci = Components.interfaces;
+const Cu = Components.utils;
var Arr = {};
// ********************************************************************************************* //
@@ -33,17 +34,29 @@ Arr.isArrayLike = function(obj)
return true;
if (typeof obj.splice === "function") // jQuery etc.
return true;
- if (obj instanceof Ci.nsIDOMHTMLCollection)
+ if (Arr._isDOMTokenList(obj))
return true;
- if (obj instanceof Ci.nsIDOMNodeList)
- return true;
- if (obj instanceof Ci.nsIDOMDOMTokenList)
+ var str = Object.prototype.toString.call(obj);
+ if (str === "[object HTMLCollection]" || str === "[object NodeList]")
return true;
}
catch (exc) {}
return false;
};
+Arr._isDOMTokenList = function(obj)
+{
+ // When minVersion is 19 or so, we can replace this whole function with
+ // (Object.prototype.toString.call(obj) === "[object DOMTokenList]").
+ try
+ {
+ var uwGlobal = XPCNativeWrapper.unwrap(Cu.getGlobalForObject(obj));
+ return obj instanceof uwGlobal.DOMTokenList;
+ }
+ catch (exc) {}
+ return false;
+};
+
// At least sometimes the keys will be on user-level window objects
Arr.keys = function(map)
{
--
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