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

add element.hasProperties method #2321

Closed
ianstormtaylor opened this issue Oct 25, 2018 · 1 comment
Closed

add element.hasProperties method #2321

ianstormtaylor opened this issue Oct 25, 2018 · 1 comment
Labels

Comments

@ianstormtaylor
Copy link
Owner

ianstormtaylor commented Oct 25, 2018

Do you want to request a feature or report a bug?

Feature.

What's the current behavior?

It's common to want to check whether an element (inline/block) matches a specific set of properties. The naive way is to just check element.type === type, but that doesn't account for things like headings where you might have a data.level === 2 to check as well.

What's the expected behavior?

We should add a method that makes this easy to check. It should take Object|String, and use Block.createProperties to normalize them. And then check to see if the element has the properties in question.

block.hasProperties('quote')
inline.hasProperties({ type: 'inline', data: { url: 'https://example.com' }})

I think we should also add a getProperties that returns just the settable properties of the element (ie. type and data), omitting the other things that are present when fully serializing.

@ianstormtaylor
Copy link
Owner Author

Fixed by #3093.

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

Successfully merging a pull request may close this issue.

1 participant