Attributes support in serialize/deserialize functions [wsdl2js]
Added attributes support in serialize and deserialize functions:
Serialize:
function OBJECT_serialize(cxfjsutils, elementName, extraNamespaces) {
/* some code .... */
if (this._value !== null) {
xml = xml + 'value="' + this._value + '" ';
}
// It support also default values:
if (this._timeout !== null) {
xml = xml + 'timeout="' + this._timeout + '" ';
} else {
xml = xml + 'timeout="0" ';
}
}
Deserialize:
function OBJECT_deserialize(cxfjsutils, element) {
/* some code .... */
var attributes = element.attributes;
for (var i = 0; i < attributes.length; i++) {
if (attributes[i].nodeName === 'timeout') {
newobject.setTimeout(attributes[i].nodeValue)
}
/* etc. */
}
}
Better array support:
this._item = []; // array
// Old situation (it's always override the previous value)
function OBJECT_setItem(value) { this._item = value; }
// New situation (add separate items or arrays)
function OBJECT_addItem(Item) {
(Item instanceof Array ? this._item = this._item.concat(Item) : this._item.push(Item));
}
Don't worry about the build timing out. Any chance of modifying/adding some tests for these new features?
@coheigea As you can see I have modified the unit tests in my last commit, so they runs well again.
The unit tests have been modified, but I'd prefer to see a unit test added that (for example) failed with the old code but passes with the new code. Does changing from "add" to "set" for arrays break the API by the way?
Definitely concerned about the set->add change. That will certainly break peoples code. Can the original method be retained with the add method being added?