-
Notifications
You must be signed in to change notification settings - Fork 359
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 option to return an HTMLElement from the icon helper #3126
Add option to return an HTMLElement from the icon helper #3126
Conversation
Thanks, @LuomaJuha! I'd like to get @crhallberg's opinion on this, since I believe he wrote most of the original code that's impacted. He's going to be on vacation for the next week or so, but hopefully he can look at it when he returns if he can't get to it before he leaves tomorrow. :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comments are nitpicks. This looks very good and I like the direction!
themes/bootstrap3/js/common.js
Outdated
const oldAttrs = _element.getAttribute(key); | ||
if (oldAttrs !== null) { | ||
newAttrs = [...newAttrs, ...oldAttrs.split(" ")]; | ||
// Remove duplicate values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use a Set to remove duplicate values as you compile them.
const newAttrsSet = new Set([...newAttrs, ...oldAttrs.split(" ")]);
//...
_element.setAttribute(key, Array.from(newAttrsSet).join(" "));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there other attributes that require space separated strings other than class? If we're going to be working on an Element directly, I'd like Element to do as much work as possible. This actually makes me think we should be overriding the attributes instead of appending them (except for class). I know this is based on my code but I've since learned how complicated this can get.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I would think that class could be the only one, only if there is some custom datasets but otherwise shouldn't be, ill try and adjust
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@crhallberg made some small changes where if the key is not class then just sets it instantly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @LuomaJuha! @crhallberg, do you mind taking another look at this when you have a chance?
I suspect we'll be able to merge this soon, but since things are getting locked down for 9.1, it will probably have to wait for release 10.0. I'm setting a milestone to be sure we don't lose track of it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those changes! I was thinking about using classList for this, but I think that would lead to more confusing code. Thank you!
Thanks, @LuomaJuha and @crhallberg! |
Sometimes it is easier to manipulate the icon when it is an HTMLElement like when assigining it into a value, so here is a small adjustment for the icon function.