[Groonga-commit] groonga/gcs [master] Support null and array for addFragment()

Back to archive index

null+****@clear***** null+****@clear*****
2012年 7月 19日 (木) 18:10:00 JST


SHIMODA Hiroshi	2012-07-19 18:10:00 +0900 (Thu, 19 Jul 2012)

  New Revision: 8734bf9d679646e4c01758698fce66dac62e4ca3
  https://github.com/groonga/gcs/commit/8734bf9d679646e4c01758698fce66dac62e4ca3

  Log:
    Support null and array for addFragment()

  Modified files:
    lib/xmlbuilder.js

  Modified: lib/xmlbuilder.js (+9 -3)
===================================================================
--- lib/xmlbuilder.js    2012-07-19 18:06:44 +0900 (c559ea3)
+++ lib/xmlbuilder.js    2012-07-19 18:10:00 +0900 (49ea3cd)
@@ -1,9 +1,15 @@
 module.exports = require('xmlbuilder');
 module.exports.XMLFragment = require('xmlbuilder/lib/XMLFragment');
 
-module.exports.XMLFragment.prototype.addFragment = function(fragment) {
-  fragment.parent = this;
-  this.children.push(fragment);
+module.exports.XMLFragment.prototype.addFragment = function(fragments) {
+  if (fragments) {
+    if (!Array.isArray(fragments))
+      fragments = [fragments];
+    fragments.forEach(function(fragment) {
+      fragment.parent = this;
+      this.children.push(fragment);
+    }, this);
+  }
   return this;
 };
 
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
下载 



Groonga-commit メーリングリストの案内
Back to archive index