-
Notifications
You must be signed in to change notification settings - Fork 33
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
Optional Attributes returning wrong Type #6
Comments
You're right, it should return |
Simply call This should really be documented. However, it's likely that the syntax for removing also mandatory elements / attributes will soon be something like Note that console.log( dir.file[0]._exists ); The A remaining issue is that the placeholders for strings and numbers should probably never be objects that evaluate as |
Should init() be called before or after parsing? |
It's called before parsing. |
That did the trick, thanks! Should this issue be closed as a workaround is available, or left open for tracking of the cleanPlaceholders fix? |
Let's keep it open. I'm doing a major rewrite which should speed up the parsing quite a bit, and will have to keep this issue in mind. |
When an optional attribute is omitted from an xml document, attempting to retrieve the attribute value should return undefined or null, but instead returns an untyped object with _exist: false. This means that null checks against these optional attributes pass, even when they are not specified.
For example, at https://github.com/charto/cxml/blob/master/test/dir-example.ts#L50 , if you were to add:
let inode = doc.dir.inode || ''
the value ofinode
would be an object with _exists: false, not a string representing the inode of the directory.Have I missed some handy feature for detecting unspecified optional attributes?
The text was updated successfully, but these errors were encountered: