Skip to content
Browse files

Merge pull request #3 from fjakobs/patch-1

declare variables using "var" to prevent them from leaking into the global scope
  • Loading branch information...
2 parents 466fca4 + 9d062f3 commit 9fa3b121710cfb17c55c12bb929cb51e160581c2 @teknopaul committed Mar 6, 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 9fa3b12

Please sign in to comment.
Something went wrong with that request. Please try again.