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

Method supportedValue should support !important property. #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LvChengbin
Copy link

@LvChengbin LvChengbin changed the title fixed #214 Method supportedValue should support !important property. #214 Aug 23, 2020
@LvChengbin LvChengbin changed the title Method supportedValue should support !important property. #214 Method supportedValue should support !important property. Aug 23, 2020
@@ -64,7 +64,7 @@ export default function supportedValue(property, value) {
// IE can even throw an error in some cases, for e.g. style.content = 'bar'.
try {
// Test value as it is.
el.style[property] = prefixedValue
el.style.setProperty(property, ...prefixedValue.split(/!(?=important$)/))
Copy link
Member

@kof kof Aug 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I think we don't need to pass important for the test at all, because the result for our tests should be the same no matter if there is important or not, we can get rid of spread operator here as well
  2. we need to do some micro benchmarking on esbench to see what's the fastest way to get rid of "important", I would guess str.replace will be much faster than doing the split

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is this hsould be the fastest: .replace(/!important[\s]*$/, '') - I think supporting accidental whitespace at the end is a good idea

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

Successfully merging this pull request may close these issues.

Method supportedValue should support !important property.
2 participants