Skip to content

Loading…

Inconsistency with prefixed elements #15

Closed
frane opened this Issue · 3 comments

2 participants

@frane

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
node-XMPP member

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
node-XMPP member

Released in 0.2.2

@astro astro closed this
@frane

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
Something went wrong with that request. Please try again.