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

Inconsistency with prefixed elements #15

Closed
frane opened this issue Aug 8, 2012 · 3 comments
Closed

Inconsistency with prefixed elements #15

frane opened this issue Aug 8, 2012 · 3 comments

Comments

@frane
Copy link

frane commented Aug 8, 2012

The getChild, getChildren and getChildText methods behave inconsistently on prefixed elements.

Example:

el = ltx.parse('<root><x:foo>bar</x:foo></root>');

el.getChildText('x:foo')
// result: 'bar'

el.getChildText('foo')
// result: null

el.getChild('x:foo')
// result: null -> can't try getText :-)

el.getChild('foo').getText()
// result: 'bar'

getChildText uses this.name to find the child while getChildren, and thus getChild, uses this.getName(). However, this behavior should be consistent to avoid confusion and bugs.

@astro
Copy link
Member

astro commented Aug 13, 2012

Agreed. Thanks for reporting.

I'm removing the ability to specify the prefix at all. Pass a full namespace instead. I hope you don't see this as a limitation, prefixes depend on specific implementations and you shouldn't hard code any.

astro added a commit that referenced this issue Aug 13, 2012
@astro
Copy link
Member

astro commented Aug 13, 2012

Released in 0.2.2

@astro astro closed this as completed Aug 13, 2012
@frane
Copy link
Author

frane commented Aug 13, 2012

Your solution works for me. The methods are consistent now and your argument hardcoded prefixes is absolutely valid.
Thanks for fixing!

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

No branches or pull requests

2 participants