-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Updated replace() to pass id from placeholder element #193
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ export default function toSvg(key, options = {}) { | |
|
|
||
| combinedOptions.class = addDefaultClassNames(combinedOptions.class, key); | ||
|
|
||
| const attributes = optionsToAtrributes(combinedOptions); | ||
| const attributes = optionsToAttributes(combinedOptions); | ||
|
|
||
| return `<svg ${attributes}>${icons[key]}</svg>`; | ||
| } | ||
|
|
@@ -64,11 +64,13 @@ function addDefaultClassNames(classNames, key) { | |
| * @param {Object} options | ||
| * @returns {string} | ||
| */ | ||
| function optionsToAtrributes(options) { | ||
| function optionsToAttributes(options) { | ||
| const attributes = []; | ||
|
|
||
| Object.keys(options).forEach(key => { | ||
| attributes.push(`${key}="${options[key]}"`); | ||
| if (options[key]) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When would
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case it was the lack of a value for I could instead check if id has a value before passing it as an option to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha. I didn't think about that. I think this is fine!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may be a good idea to use TypeScript to catch these kinds of bugs 😄 |
||
| attributes.push(`${key}="${options[key]}"`); | ||
| } | ||
| }); | ||
|
|
||
| return attributes.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.
Haha thanks for catching my typo!