simple-dom
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -392,2 +392,17 @@ (function (global, factory) { | ||
var ESC = { | ||
'<': '<', | ||
'>': '>', | ||
'"': '"', | ||
'&': '&' | ||
}; | ||
function matcher(char) { | ||
if (ESC[char] === undefined) { | ||
return char; | ||
} | ||
return ESC[char]; | ||
} | ||
function HTMLSerializer(voidMap) { | ||
@@ -418,10 +433,7 @@ this.voidMap = voidMap; | ||
HTMLSerializer.prototype.escapeAttrValue = function(attrValue) { | ||
return attrValue.replace(/[&"]/g, function(match) { | ||
switch(match) { | ||
case '&': | ||
return '&'; | ||
case '\"': | ||
return '"'; | ||
} | ||
}); | ||
if (attrValue.indexOf('&') > -1 || attrValue.indexOf('"') > -1) { | ||
return attrValue.replace(/[&"]/g, matcher); | ||
} | ||
return attrValue; | ||
}; | ||
@@ -440,12 +452,10 @@ | ||
HTMLSerializer.prototype.escapeText = function(textNodeValue) { | ||
return textNodeValue.replace(/[&<>]/g, function(match) { | ||
switch(match) { | ||
case '&': | ||
return '&'; | ||
case '<': | ||
return '<'; | ||
case '>': | ||
return '>'; | ||
} | ||
}); | ||
if (textNodeValue.indexOf('>') > -1 || | ||
textNodeValue.indexOf('<') > -1 || | ||
textNodeValue.indexOf('&') > -1 | ||
) { | ||
return textNodeValue.replace(/[&<>]/g, matcher); | ||
} | ||
return textNodeValue; | ||
}; | ||
@@ -452,0 +462,0 @@ |
@@ -0,1 +1,16 @@ | ||
var ESC = { | ||
'<': '<', | ||
'>': '>', | ||
'"': '"', | ||
'&': '&' | ||
}; | ||
function matcher(char) { | ||
if (ESC[char] === undefined) { | ||
return char; | ||
} | ||
return ESC[char]; | ||
} | ||
function HTMLSerializer(voidMap) { | ||
@@ -26,10 +41,7 @@ this.voidMap = voidMap; | ||
HTMLSerializer.prototype.escapeAttrValue = function(attrValue) { | ||
return attrValue.replace(/[&"]/g, function(match) { | ||
switch(match) { | ||
case '&': | ||
return '&'; | ||
case '\"': | ||
return '"'; | ||
} | ||
}); | ||
if (attrValue.indexOf('&') > -1 || attrValue.indexOf('"') > -1) { | ||
return attrValue.replace(/[&"]/g, matcher); | ||
} | ||
return attrValue; | ||
}; | ||
@@ -48,12 +60,10 @@ | ||
HTMLSerializer.prototype.escapeText = function(textNodeValue) { | ||
return textNodeValue.replace(/[&<>]/g, function(match) { | ||
switch(match) { | ||
case '&': | ||
return '&'; | ||
case '<': | ||
return '<'; | ||
case '>': | ||
return '>'; | ||
} | ||
}); | ||
if (textNodeValue.indexOf('>') > -1 || | ||
textNodeValue.indexOf('<') > -1 || | ||
textNodeValue.indexOf('&') > -1 | ||
) { | ||
return textNodeValue.replace(/[&<>]/g, matcher); | ||
} | ||
return textNodeValue; | ||
}; | ||
@@ -60,0 +70,0 @@ |
{ | ||
"name": "simple-dom", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A simple JS DOM.", | ||
@@ -15,3 +15,4 @@ "main": "dist/simple-dom.js", | ||
"build": "node bin/build.js", | ||
"test": "testem ci" | ||
"test": "testem ci", | ||
"bench": "npm run build && node ./benches/serialize.js" | ||
}, | ||
@@ -31,2 +32,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"do-you-even-bench": "^1.0.4", | ||
"qunit-extras": "^3.0.0", | ||
@@ -33,0 +35,0 @@ "qunitjs": "^2.4.0", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
467152
2389
6