Skip to content

Commit

Permalink
more jslint nits... now under 300, and ecma5 strict mode only complai…
Browse files Browse the repository at this point in the history
…ns about 5 items (without the parser)
  • Loading branch information
client9 committed Mar 30, 2010
1 parent f01167f commit d2dc84f
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 37 deletions.
40 changes: 23 additions & 17 deletions src/dom/document.js
@@ -1,4 +1,9 @@

/*
* Forward declarations
*/
var __isValidNamespace__;

/**
* @class Document - The Document interface represents the entire HTML
* or XML document. Conceptually, it is the root of the document tree,
Expand Down Expand Up @@ -41,7 +46,7 @@ __extend__(Document.prototype,{
get documentElement(){
var i, length = this.childNodes?this.childNodes.length:0;
for(i=0;i<length;i++){
if(this.childNodes[i].nodeType == Node.ELEMENT_NODE){
if(this.childNodes[i].nodeType === Node.ELEMENT_NODE){
return this.childNodes[i];
}
}
Expand Down Expand Up @@ -156,7 +161,7 @@ __extend__(Document.prototype,{
}
var node = new Attr(this);
var qname = __parseQName__(qualifiedName);
node.namespaceURI = namespaceURI===''?null:namespaceURI;
node.namespaceURI = namespaceURI === '' ? null : namespaceURI;
node.prefix = qname.prefix;
node.nodeName = qualifiedName;
node.nodeValue = "";
Expand Down Expand Up @@ -212,24 +217,27 @@ __extend__(Document.prototype,{
get xml(){
return this.documentElement.xml;
},
toString: function(){
return "[object XMLDocument]";
toString: function(){
return "[object XMLDocument]";
},
get defaultView(){
return { getComputedStyle: function(elem){
return window.getComputedStyle(elem);
}};
},
get defaultView(){
return { getComputedStyle: function(elem){
return window.getComputedStyle(elem);
}};
},
get styleSheets(){
/*TODO*/
return [];
}
});

/*
* Helper function
*
*/
__isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribute) {

var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribute) {

if (doc.importing == true) {
if (doc.importing === true) {
//we're doing an importNode operation (or a cloneNode) - in both cases, there
//is no need to perform any namespace checking since the nodes have to have been valid
//to have gotten into the DOM in the first place
Expand All @@ -242,7 +250,7 @@ var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribut


//only check for namespaces if we're finished parsing
if (this.parsing == false) {
if (this.parsing === false) {

// if the qualifiedName is malformed
if (qName.localName.indexOf(":") > -1 ){
Expand All @@ -257,18 +265,16 @@ var __isValidNamespace__ = function(doc, namespaceURI, qualifiedName, isAttribut
}

// if the qualifiedName has a prefix
if ((valid) && (qName.prefix == "")) {
if ((valid) && (qName.prefix === "")) {
valid = false;
}

}

// if the qualifiedName has a prefix that is "xml" and the namespaceURI is
// different from "http://www.w3.org/XML/1998/namespace" [Namespaces].
if ((valid) && (qName.prefix == "xml") && (namespaceURI != "http://www.w3.org/XML/1998/namespace")) {
if ((valid) && (qName.prefix === "xml") && (namespaceURI !== "http://www.w3.org/XML/1998/namespace")) {
valid = false;
}

return valid;
};

12 changes: 7 additions & 5 deletions src/platform/core/__global__.js
@@ -1,5 +1,5 @@
/*
* Envjs @VERSION@
* Envjs @VERSION@
* Pure JavaScript Browser Environment
* By John Resig <http://ejohn.org/> and the Envjs Team
* Copyright 2008-2010 John Resig, under the MIT License
Expand All @@ -11,13 +11,14 @@ var Envjs = function(){
override = function(){
for(i=0;i<arguments.length;i++){
for ( name in arguments[i] ) {
var g = arguments[i].__lookupGetter__(name),
var g = arguments[i].__lookupGetter__(name),
s = arguments[i].__lookupSetter__(name);
if ( g || s ) {
if ( g ) Envjs.__defineGetter__(name, g);
if ( s ) Envjs.__defineSetter__(name, s);
} else
if ( g ) { Envjs.__defineGetter__(name, g); }
if ( s ) { Envjs.__defineSetter__(name, s); }
} else {
Envjs[name] = arguments[i][name];
}
}
}
};
Expand All @@ -40,3 +41,4 @@ Envjs.appCodeName = "Envjs";
Envjs.appName = "Resig/20070309 PilotFish/@BUILD_VERSION@";

Envjs.version = "1.6";//?
Envjs.revision = '';
26 changes: 14 additions & 12 deletions src/window/window.js
@@ -1,6 +1,19 @@
//These descriptions of window properties are taken loosely David Flanagan's
//'JavaScript - The Definitive Guide' (O'Reilly)


var __top__ = function(_scope){
var _parent = _scope.parent;
while (_scope && _parent && _scope !== _parent) {
if (_parent === _parent.parent) {
break;
}
_parent = _parent.parent;
//console.log('scope %s _parent %s', scope, _parent);
}
return _parent || null;
}

/**
* Window
* @param {Object} scope
Expand Down Expand Up @@ -215,7 +228,7 @@ Window = function(scope, parent, opener){
// If this window is a frame, the top property refers to the top-level
// window that contains the frame.
get top(){
return __top__(scope)
return __top__(scope);
},
get window(){
return this;
Expand Down Expand Up @@ -284,17 +297,6 @@ Window = function(scope, parent, opener){

};

var __top__ = function(_scope){
var _parent = _scope.parent;
while (_scope && _parent && _scope !== _parent) {
if (_parent === _parent.parent) {
break;
}
_parent = _parent.parent;
//console.log('scope %s _parent %s', scope, _parent);
}
return _parent || null;
}

var __windows__ = {};

Expand Down
3 changes: 2 additions & 1 deletion src/xhr/document.js
Expand Up @@ -18,7 +18,8 @@ __extend__(Document.prototype,{
set location(url){
//very important or you will go into an infinite
//loop when creating a xml document
if(url)
if(url) {
this.location.replace(url);
}
}
});
2 changes: 1 addition & 1 deletion src/xhr/form.js
Expand Up @@ -151,7 +151,7 @@ var __fieldSerialize__ = function(inputs, successful) {
input = inputs[i];
name = input.name;
if (!name) {
return;
return '';
}
value = __fieldValue__(input, successful);
if (value && value.constructor == Array) {
Expand Down
2 changes: 1 addition & 1 deletion src/xhr/location.js
Expand Up @@ -69,7 +69,7 @@ Location = function(url, doc, history) {
},
set hostname(s) {
if (!s || s === '') {
return '';
return;
}

parts.netloc = s;
Expand Down

0 comments on commit d2dc84f

Please sign in to comment.