[Pkg-javascript-commits] [ltx] 171/469: element: don't serialize null/undefined attributes
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:01:21 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository ltx.
commit 21d6c96d1f38279a0f7e2ca78491233c04f8b514
Author: Astro <astro at spaceboyz.net>
Date: Mon Jan 31 18:38:23 2011 +0100
element: don't serialize null/undefined attributes
---
lib/element.js | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/lib/element.js b/lib/element.js
index f6bd973..c583375 100644
--- a/lib/element.js
+++ b/lib/element.js
@@ -151,14 +151,16 @@ Element.prototype.write = function(writer) {
writer("<");
writer(this.name);
for(var k in this.attrs) {
- writer(" ");
- writer(k);
- writer("=\"");
var v = this.attrs[k];
- if (typeof v != 'string')
- v = v.toString();
- writer(escapeXml(v));
- writer("\"");
+ if (v || v === '') {
+ writer(" ");
+ writer(k);
+ writer("=\"");
+ if (typeof v != 'string')
+ v = v.toString();
+ writer(escapeXml(v));
+ writer("\"");
+ }
}
if (this.children.length == 0) {
writer("/>");
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/ltx.git
More information about the Pkg-javascript-commits
mailing list