asciidoctorj icon indicating copy to clipboard operation
asciidoctorj copied to clipboard

Add single argument version of ContentNode#hasAttr

Open mojavelinux opened this issue 8 years ago • 4 comments

Add a single argument version of the method ContentNode#isAttr. The purpose of this method is to determine whether an attribute is set, regardless of the value. For example:

document.isAttr("sectnums");

The method will also need to accept a boolean flag to control whether to consider the inherited attribute (which is true by default).

node.isAttr("target", false);

If this method conflicts with other overloaded methods, we could consider changing the prefix to has.

document.hasAttr("sectnums")

This may actually be a better approach. This is consistent with the DOM (which uses the method name hasAttribute).

mojavelinux avatar Jul 17 '16 00:07 mojavelinux

@robertpanzer if you like hasAttr instead of isAttr, feel free to update the title of the issue.

mojavelinux avatar Jul 17 '16 00:07 mojavelinux

In Asciidoctor.js, we decided to use more formal names, like getAttribute and setAttribute. I wonder if we should do the same in AsciidoctorJ 1.6.

mojavelinux avatar May 10 '17 09:05 mojavelinux

I would be in favor of doing so. Method names isAttr and getAttr don't feel very Java-like.

robertpanzer avatar May 10 '17 09:05 robertpanzer

Exactly what we concluded for Asciidoctor.js. cc: @Mogztter

mojavelinux avatar May 10 '17 10:05 mojavelinux