[Pkg-javascript-commits] [ltx] 346/469: add toJSON to element
Jonas Smedegaard
dr at jones.dk
Wed Aug 31 13:03:24 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 8232d631a8de74a59a69668f4f709c38f74daf17
Author: ▟ ▖▟ ▖ <dodo.the.last at gmail.com>
Date: Thu Sep 18 00:34:10 2014 +0200
add toJSON to element
---
lib/element.js | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/lib/element.js b/lib/element.js
index 0975909..0c77dc1 100644
--- a/lib/element.js
+++ b/lib/element.js
@@ -303,6 +303,16 @@ Element.prototype.toString = function() {
return s
}
+Element.prototype.toJSON = function() {
+ return {
+ name: this.name,
+ attrs: this.attrs,
+ children: this.children.map(function(child) {
+ return child && child.toJSON ? child.toJSON() : child;
+ })
+ }
+}
+
Element.prototype._addChildren = function(writer) {
writer('>')
for (var i = 0; i < this.children.length; i++) {
--
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