Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attributes support in serialize/deserialize functions [wsdl2js] #256

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

R-ens
Copy link

@R-ens R-ens commented Apr 10, 2017

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));
}

Rens van der Linden added 2 commits April 10, 2017 10:56
@R-ens R-ens changed the title Add attributes in serialize functions Attributes support in serialize/deserialize functions [wsdl2js] Apr 11, 2017
@coheigea
Copy link
Contributor

Don't worry about the build timing out. Any chance of modifying/adding some tests for these new features?

@R-ens
Copy link
Author

R-ens commented Apr 14, 2017

@coheigea As you can see I have modified the unit tests in my last commit, so they runs well again.

@coheigea
Copy link
Contributor

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?

@dkulp
Copy link
Member

dkulp commented May 3, 2017

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants