Skip to content

XmlConfigParser.parseVo bug using ASC2.0 #15

@ianmcgregor

Description

@ianmcgregor

Hi Matan,

First off, thanks for creating such a great loading library :)

I started a new project today using ASC2.0 and found that AssetLoader is throwing errors due to invalid config values (in my case ConfigVO.type and ConfigVO.blendMode).

I've tracked it down to the XmlConfigParser.parseVo method. What is happening is that using the old compiler the XML attribute queries return null where the attribute does not exist, allowing the OR expression to select the value from the 'inheritFrom' VO. Using the new compiler, the attribute queries appear to be returning an empty XMLList. When assigned to the string properties in ConfigVO, you end up with empty strings for properties such as 'type', which breaks things later on.

child.type = xml.@type || inheritFrom.type;

So the above code will assign xml.@type even when it doesn't exist.

Now, I don't know whether to consider this a bug with ASC2.0 or AssetLoader, but I've found a couple of potential solutions I thought I'd run by you before submitting any pull request:

child.type = xml.hasOwnProperty("@type") ? xml.@type : inheritFrom.type;

child.type = xml.attribute("@type").length() > 0 ? xml.@type : inheritFrom.type;

I'm sure there are several other ways to approach it too. Shame to lose the simple OR assignment, I'm a bit fan of its simplicity, but I really want to start using ASC2.0 and AssetLoader!

Thanks for your time,
Ian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions