Add utility function to split string into component values#209
Add utility function to split string into component values#209bramus merged 1 commit intoflackr:masterfrom
Conversation
fb9ecee to
e7b8d1a
Compare
c590806 to
1afa09f
Compare
bramus
left a comment
There was a problem hiding this comment.
Overall structure looks good. A few remarks to address.
1afa09f to
8e1896c
Compare
Thanks for the review @bramus 🙏 I think I've addressed all your remarks: https://github.com/flackr/scroll-timeline/compare/1afa09f2c7a3c39efc4a348f0940fd6fb6b03085..8e1896c3c547119a6bafed25ffd764f0efd786b4 |
|
Just came to the realization one can perfectly author something like Now, I don’t think anyone would write such a declaration and consider this be an extreme edge case, so I’m fine with merging this as is. /ping @flackr for an opinion on this. |
We could easily handle that in |
8e1896c to
14cde5b
Compare
|
Updated the PR to support |
When parsing component values passed as a string to
rangeStart,rangeEndandinsetwe have previously used str.split(), either with a single whitespace or with a regex with various issues:'calc(2 * 10px) auto'.split(' ')returns['calc(2', '*', '10px)', 'auto'], breaking apart functions'calc(2 * 10px) auto'.split(/(?<!\([^\)]*)\s(?![^\(]*\))/)returns['calc(2 * 10px)', 'auto']as expected, but causes an error in browsers without support for lookaheadThis PR adds a utility function
splitIntoComponentValues(input)that splits a string with multiple component values into an array of individual component value strings. These can then be processed either as keywords or be further parsed usingCSSNumericValue.parse().