Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replaced magic numbers for node types by constants

  • Loading branch information...
commit ad14420448648ec9031fffeb6facb44d141d539f 1 parent 260813d
@SebastianZ SebastianZ authored janodvarko committed
View
8 extension/content/firebug/accessible/a11y.js
@@ -2241,7 +2241,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
box.a11yCaretOffset = offset = 0;
}
var startNode = node.getElementsByClassName("sourceRowText").item(0)
- if (startNode && startNode.firstChild && startNode.firstChild.nodeType == 3)
+ if (startNode && startNode.firstChild && startNode.firstChild.nodeType == Node.TEXT_NODE)
{
startNode = startNode.firstChild;
if (offset >= startNode.length)
@@ -2948,7 +2948,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
isVisibleByStyle: function (elem)
{
- if (!elem || elem.nodeType != 1)
+ if (!elem || elem.nodeType != Node.ELEMENT_NODE)
return false;
var style = elem.ownerDocument.defaultView.getComputedStyle(elem, null);
return style.visibility !== "hidden" && style.display !== "none";
@@ -3027,7 +3027,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
return null;
function criteria(node) {
- return node.nodeType == 1 && Css.hasClass(node, className);
+ return node.nodeType == Node.ELEMENT_NODE && Css.hasClass(node, className);
}
for (var sib = node.previousSibling; sib; sib = sib.previousSibling)
@@ -3062,7 +3062,7 @@ Firebug.A11yModel = Obj.extend(Firebug.Module,
return null;
function criteria(node) {
- return node.nodeType == 1 && Css.hasClass(node, className);
+ return node.nodeType == Node.ELEMENT_NODE && Css.hasClass(node, className);
}
if (!upOnly)
View
5 extension/content/firebug/css/cssPanel.js
@@ -1489,7 +1489,10 @@ Firebug.CSSStyleSheetPanel.prototype = Obj.extend(Firebug.Panel,
}
else
{
- function findRow(node) { return node.nodeType == 1 ? node : node.parentNode; }
+ function findRow(node) {
+ return node.nodeType == Node.ELEMENT_NODE ? node : node.parentNode;
+ }
+
this.currentSearch = new Search.TextSearch(this.panelNode, findRow);
row = this.currentSearch.find(text, reverse, Firebug.Search.isCaseSensitive(text));
}
View
2  extension/content/firebug/css/stylePanel.js
@@ -205,7 +205,7 @@ CSSStylePanel.prototype = Obj.extend(CSSStyleSheetPanel.prototype,
getInheritedRules: function(element, sections, usedProps)
{
var parent = element.parentNode;
- if (parent && parent.nodeType == 1)
+ if (parent && parent.nodeType == Node.ELEMENT_NODE)
{
this.getInheritedRules(parent, sections, usedProps);
View
14 extension/content/firebug/html/htmlPanel.js
@@ -798,7 +798,7 @@ Firebug.HTMLPanel.prototype = Obj.extend(WalkingPanel,
if (parentNode)
{
- if (parentNode.nodeType == 9) // then parentNode is Document element
+ if (parentNode.nodeType == Node.DOCUMENT_NODE)
{
if (parentNode.defaultView)
{
@@ -807,8 +807,8 @@ Firebug.HTMLPanel.prototype = Obj.extend(WalkingPanel,
if (FBTrace.DBG_HTML)
{
- FBTrace.sysout("getParentObject parentNode.nodeType 9, frameElement:"+
- parentNode.defaultView.frameElement);
+ FBTrace.sysout("getParentObject; node is document node"+
+ ", frameElement:" + parentNode.defaultView.frameElement);
}
return parentNode.defaultView.frameElement;
@@ -841,7 +841,7 @@ Firebug.HTMLPanel.prototype = Obj.extend(WalkingPanel,
{
// Documents have no parentNode; Attr, Document, DocumentFragment, Entity,
// and Notation. top level windows have no parentNode
- if (node && node.nodeType == 9) // document type
+ if (node && node.nodeType == Node.DOCUMENT_NODE)
{
// generally a reference to the window object for the document, however
// that is not defined in the specification
@@ -1597,7 +1597,7 @@ Firebug.HTMLPanel.prototype = Obj.extend(WalkingPanel,
var items = [];
- if (node.nodeType == 1)
+ if (node.nodeType == Node.ELEMENT_NODE)
{
items.push(
"-",
@@ -1710,7 +1710,7 @@ Firebug.HTMLPanel.prototype = Obj.extend(WalkingPanel,
return;
var node = Firebug.getRepObject(target);
- if (node && node.nodeType == 1)
+ if (node && node.nodeType == Node.ELEMENT_NODE)
{
var nodeName = node.localName.toUpperCase();
var attribute = Dom.getAncestorByClass(target, "nodeAttr");
@@ -2647,7 +2647,7 @@ Firebug.HTMLModule.MutationBreakpoints =
getContextMenuItems: function(context, node, target, items)
{
- if (!(node && node.nodeType == 1))
+ if (!(node && node.nodeType == Node.ELEMENT_NODE))
return;
var breakpoints = context.mutationBreakpoints;
View
2  extension/content/firebug/html/inspector.js
@@ -250,7 +250,7 @@ Firebug.Inspector = Obj.extend(Firebug.Module,
*/
inspectNode: function(node)
{
- if (node && node.nodeType != 1)
+ if (node && node.nodeType != Node.ELEMENT_NODE)
node = node.parentNode;
if (node && Firebug.shouldIgnore(node) && !node.fbProxyFor)
View
8 extension/content/firebug/lib/css.js
@@ -237,7 +237,7 @@ Css.getElementCSSPath = function(element)
{
var paths = [];
- for (; element && element.nodeType == 1; element = element.parentNode)
+ for (; element && element.nodeType == Node.ELEMENT_NODE; element = element.parentNode)
{
var selector = Css.getElementCSSSelector(element);
paths.splice(0, 0, selector);
@@ -253,7 +253,7 @@ var classNameReCache={};
Css.hasClass = function(node, name)
{
- if (!node || node.nodeType != 1 || !node.className || name == '')
+ if (!node || node.nodeType != Node.ELEMENT_NODE || !node.className || name == '')
return false;
if (name.indexOf(" ") != -1)
@@ -282,7 +282,7 @@ Css.hasClass = function(node, name)
Css.setClass = function(node, name)
{
- if (!node || node.nodeType != 1 || name == '')
+ if (!node || node.nodeType != Node.ELEMENT_NODE || name == '')
return;
if (name.indexOf(" ") != -1)
@@ -311,7 +311,7 @@ Css.getClassValue = function(node, name)
Css.removeClass = function(node, name)
{
- if (!node || node.nodeType != 1 || node.className == '' || name == '')
+ if (!node || node.nodeType != Node.ELEMENT_NODE || node.className == '' || name == '')
return;
if (name.indexOf(" ") != -1)
View
12 extension/content/firebug/lib/dom.js
@@ -116,7 +116,7 @@ Dom.isAncestor = function(node, potentialAncestor)
Dom.getNextElement = function(node)
{
- while (node && node.nodeType != 1)
+ while (node && node.nodeType != Node.ELEMENT_NODE)
node = node.nextSibling;
return node;
@@ -124,7 +124,7 @@ Dom.getNextElement = function(node)
Dom.getPreviousElement = function(node)
{
- while (node && node.nodeType != 1)
+ while (node && node.nodeType != Node.ELEMENT_NODE)
node = node.previousSibling;
return node;
@@ -292,7 +292,7 @@ Dom.hasChildElements = function(node)
for (var child = node.firstChild; child; child = child.nextSibling)
{
- if (child.nodeType == 1)
+ if (child.nodeType == Node.ELEMENT_NODE)
return true;
}
@@ -303,13 +303,13 @@ Dom.hasChildElements = function(node)
Dom.getNextByClass = function(root, state)
{
- function iter(node) { return node.nodeType == 1 && Css.hasClass(node, state); }
+ function iter(node) { return node.nodeType == Node.ELEMENT_NODE && Css.hasClass(node, state); }
return Dom.findNext(root, iter);
};
Dom.getPreviousByClass = function(root, state)
{
- function iter(node) { return node.nodeType == 1 && Css.hasClass(node, state); }
+ function iter(node) { return node.nodeType == Node.ELEMENT_NODE && Css.hasClass(node, state); }
return Dom.findPrevious(root, iter);
};
@@ -420,7 +420,7 @@ Dom.getClientOffset = function(elt)
if (p)
{
- if (p.nodeType == 1)
+ if (p.nodeType == Node.ELEMENT_NODE)
addOffset(p, coords, view);
}
else if (elt.ownerDocument.defaultView.frameElement)
View
4 extension/content/firebug/lib/domplate.js
@@ -1164,14 +1164,14 @@ var Renderer =
var html = this.renderHTML(args, outputs, self);
var root;
- if (parent.nodeType == 1)
+ if (parent.nodeType == Node.ELEMENT_NODE)
{
parent.innerHTML = html;
root = parent.firstChild;
}
else
{
- if (!parent || parent.nodeType != 9)
+ if (!parent || parent.nodeType != Node.DOCUMENT_NODE)
parent = document;
if (!womb || womb.ownerDocument != parent)
View
2  extension/content/firebug/lib/xpath.js
@@ -33,7 +33,7 @@ Xpath.getElementTreeXPath = function(element)
var paths = [];
// Use nodeName (instead of localName) so namespace prefix is included (if any).
- for (; element && element.nodeType == 1; element = element.parentNode)
+ for (; element && element.nodeType == Node.ELEMENT_NODE; element = element.parentNode)
{
var index = 0;
for (var sibling = element.previousSibling; sibling; sibling = sibling.previousSibling)
Please sign in to comment.
Something went wrong with that request. Please try again.