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

Broken value prefixing #10

Open
kripod opened this issue Aug 26, 2020 · 5 comments
Open

Broken value prefixing #10

kripod opened this issue Aug 26, 2020 · 5 comments

Comments

@kripod
Copy link

kripod commented Aug 26, 2020

When calling prefixValue("position", "sticky"), it returns with "-webkit-sticky, sticky" as a plain string.

The prefixValue function would return a false positive on parameters like prefixValue("content", "'Look, I am sticky like glue!'"), resulting in strings like 'Look, I am -webkit-sticky, sticky like glue!'.

As a solution, I would like to propose checking for trimmed values and requiring an exact match. An array should be returned as a result, instead of just a plain string, so that library authors can transform it as desired.

@kitten
Copy link
Member

kitten commented Aug 26, 2020

Oh I think my mistake is simply that the check for property being "position" is missing there. I'll add that in

@kripod
Copy link
Author

kripod commented Aug 26, 2020

Thank you! Also, please return the result in an other format (e.g. an array), as I cannot split strings at , safely without affecting properties other than position.

@kitten
Copy link
Member

kitten commented Aug 27, 2020

@kripod What's the interest in splitting here? In fact, it's a tiny function so you could in theory even just copy and modify it since it doesn't handle any other case than position: sticky

@kripod
Copy link
Author

kripod commented Aug 27, 2020

The interest comes from the fact that we cannot split the returned value safely, as seen in my example in the issue’s description. As a user of the library, I wouldn’t like to check if property === "position" prior to .split(", ").

@kitten
Copy link
Member

kitten commented Aug 27, 2020

@kripod What I mean though is that these are enhancement functions, hence the bitmap signals from prefixProperty. And since prefixValue only has one case, I'd recommend that if you always need to split the value that you implement this prefixing in your own code. 😅 Otherwise all this function would do anyway is return an array of two values or the original value... or an array of the original value, which then may also contain commas. And I find this to be a poor API choice.

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

No branches or pull requests

2 participants