Permalink
Browse files

declare variables using "var" to prevent them from leaking into the g…

…lobal scope
  • Loading branch information...
1 parent 466fca4 commit 9d062f340a4c8a516c835490e4fff995f70bb783 @fjakobs fjakobs committed Feb 16, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 lib/dom-js.js
View
14 lib/dom-js.js
@@ -37,7 +37,7 @@ var strict = true;
*
* @constructor DomJS
*/
-DomJS = function() {
+var DomJS = function() {
this.root = null;
this.stack = new Array();
this.currElement = null;
@@ -50,7 +50,7 @@ DomJS.prototype.parse = function(string, cb) {
return;
}
var self = this;
- parser = sax.parser(strict);
+ var parser = sax.parser(strict);
parser.onerror = function (err) {
self.error = true;
@@ -113,7 +113,7 @@ DomJS.prototype.reset = function() {
this.error = false;
};
-escape = function(string) {
+var escape = function(string) {
return string.replace(/&/g, '&')
.replace(/>/g, '>')
.replace(/</g, '&lt;')
@@ -122,7 +122,7 @@ escape = function(string) {
};
-Element = function(name, attributes, children ) {
+var Element = function(name, attributes, children ) {
this.name = name;
this.attributes = attributes || [];
this.children = children || [];
@@ -163,21 +163,21 @@ Element.prototype.text = function() {
return null;
};
-Text = function(data){
+var Text = function(data){
this.text = data;
};
Text.prototype.toXml = function(sb) {
sb.buf += escape(this.text);
};
-Comment = function(comment) {
+var Comment = function(comment) {
this.comment = comment;
};
Comment.prototype.toXml = function(sb) {
sb.buf += '<!--' + this.comment + '-->';
};
-CDATASection = function(data){
+var CDATASection = function(data){
this.text = data || '';
};
CDATASection.prototype.toXml = function(sb) {

0 comments on commit 9d062f3

Please sign in to comment.