null+****@clear*****
null+****@clear*****
2012年 7月 19日 (木) 17:57:42 JST
SHIMODA Hiroshi 2012-07-19 17:57:42 +0900 (Thu, 19 Jul 2012) New Revision: d07b7c6c2cef6cf8a447697a272f90711cafc8ae https://github.com/groonga/gcs/commit/d07b7c6c2cef6cf8a447697a272f90711cafc8ae Log: Fix "empty text" bug by the toStirng() method of the wrapped version xmlbuilder Modified files: lib/api/2011-02-01/configuration.js lib/xmlbuilder.js Modified: lib/api/2011-02-01/configuration.js (+5 -10) =================================================================== --- lib/api/2011-02-01/configuration.js 2012-07-19 17:52:44 +0900 (65b7e85) +++ lib/api/2011-02-01/configuration.js 2012-07-19 17:57:42 +0900 (2200b7f) @@ -229,17 +229,12 @@ handlers.DefineIndexField = function(context, request, response) { function createDeleteIndexFieldResponse(options) { var doc = xmlbuilder.create(); - // This is a workaround for the problem that text() does not work when empty string is given. - // https://github.com/oozcitak/xmlbuilder-js/pull/19 - var requestId = doc.begin('DeleteIndexFieldResponse', {version: '1.0'}).attribute('xmlns', XMLNS) - .element('DeleteIndexFieldResult') - .up() + doc.begin('DeleteIndexFieldResponse', {version: '1.0'}) + .attribute('xmlns', XMLNS) + .element('DeleteIndexFieldResult').up() .element('ResponseMetadata') - .element('RequestId'); - - if (options.requestId && options.requestId !== '') { - requestId.text(options.requestId); - } + .element('RequestId').text(options.requestId || '').up() + .up(); return doc.toString(); } Modified: lib/xmlbuilder.js (+9 -0) =================================================================== --- lib/xmlbuilder.js 2012-07-19 17:52:44 +0900 (51d7ce4) +++ lib/xmlbuilder.js 2012-07-19 17:57:42 +0900 (c559ea3) @@ -1,7 +1,16 @@ 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); return this; }; + +// This is a workaround for the problem that text() does not work when empty string is given. +// https://github.com/oozcitak/xmlbuilder-js/pull/19 +var originalToString = module.exports.XMLFragment.prototype.toString; +module.exports.XMLFragment.prototype.toString = function() { + var string = originalToString.apply(this, arguments); + return string.replace(/<\/>/g, ''); +}; -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...下载