Skip to content

Commit

Permalink
declare variables using "var" to prevent them from leaking into the g…
Browse files Browse the repository at this point in the history
…lobal scope
  • Loading branch information
fjakobs committed Feb 16, 2012
1 parent 466fca4 commit 9d062f3
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/dom-js.js
Expand Up @@ -37,7 +37,7 @@ var strict = true;
* *
* @constructor DomJS * @constructor DomJS
*/ */
DomJS = function() { var DomJS = function() {
this.root = null; this.root = null;
this.stack = new Array(); this.stack = new Array();
this.currElement = null; this.currElement = null;
Expand All @@ -50,7 +50,7 @@ DomJS.prototype.parse = function(string, cb) {
return; return;
} }
var self = this; var self = this;
parser = sax.parser(strict); var parser = sax.parser(strict);


parser.onerror = function (err) { parser.onerror = function (err) {
self.error = true; self.error = true;
Expand Down Expand Up @@ -113,7 +113,7 @@ DomJS.prototype.reset = function() {
this.error = false; this.error = false;
}; };


escape = function(string) { var escape = function(string) {
return string.replace(/&/g, '&') return string.replace(/&/g, '&')
.replace(/>/g, '>') .replace(/>/g, '>')
.replace(/</g, '&lt;') .replace(/</g, '&lt;')
Expand All @@ -122,7 +122,7 @@ escape = function(string) {
}; };




Element = function(name, attributes, children ) { var Element = function(name, attributes, children ) {
this.name = name; this.name = name;
this.attributes = attributes || []; this.attributes = attributes || [];
this.children = children || []; this.children = children || [];
Expand Down Expand Up @@ -163,21 +163,21 @@ Element.prototype.text = function() {
return null; return null;
}; };


Text = function(data){ var Text = function(data){
this.text = data; this.text = data;
}; };
Text.prototype.toXml = function(sb) { Text.prototype.toXml = function(sb) {
sb.buf += escape(this.text); sb.buf += escape(this.text);
}; };


Comment = function(comment) { var Comment = function(comment) {
this.comment = comment; this.comment = comment;
}; };
Comment.prototype.toXml = function(sb) { Comment.prototype.toXml = function(sb) {
sb.buf += '<!--' + this.comment + '-->'; sb.buf += '<!--' + this.comment + '-->';
}; };


CDATASection = function(data){ var CDATASection = function(data){
this.text = data || ''; this.text = data || '';
}; };
CDATASection.prototype.toXml = function(sb) { CDATASection.prototype.toXml = function(sb) {
Expand Down

0 comments on commit 9d062f3

Please sign in to comment.