Handle id and className attributes
#50
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was using
bel+cssauron-htmlto do some component testing in a completely node environment. In this case, bel uses this module to create the document structure. However, the elements were being created with emptyidandclassNameattributes.The id and className properties on elements need to be handled a bit uniquely (others too I think but for now this is what I'm running into)
In a browser environment:
The reverse is true as well
But this isn't working the way it is currently set up. Since setAttribute('class') will not affect className, and changes to className will not the corresponding 'class' to attributes.
So two changes
idandclassNamein a way that will put them directly on the dom element in addition to adding them to_attributesobjectidandclassNameuse object-defined wrapped setters sosetAttributecan be called behind the scenes whenever these properties are set via the.operatorThis accurately mimics dom elements' behavior, so
cssauron-htmlcan work withbelin node from some pretty awesome testing :)