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

AbstractNode.hasAttribute() doesn't take into account positional attributes #1734

Open
psea opened this issue May 29, 2024 · 1 comment
Open

Comments

@psea
Copy link

psea commented May 29, 2024

Hi!

For section

[attrVal="foo",attrPos]
== some section

hasAttribute() seems to returns false for positional ($positional) attributes.

section.hasAttribute("attrVal") // true
section.hasAttribute("attrPos") // false

Is that expected behavior?


section.getAttributes()

does have positional attributes returned.

{
  attrVal: "foo",
  "$positional": [null, "attrPos"]
}

Is it ok to rely on $positional property? Is it public facing property?

@psea psea changed the title AbstractNode.hasAttribute() doesn't take into account position attributes AbstractNode.hasAttribute() doesn't take into account positional attributes May 29, 2024
@ggrossetie
Copy link
Member

I think you need to use isAttribute.
hasAttribute will indeed check if the attribute is defined (explicitly) as a named attribute. We might need to update the documentation to make that clear.

Is it ok to rely on $positional property? Is it public facing property?

No, you should avoid using $positional property.

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

No branches or pull requests

2 participants