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

Fix: Prevent error if property block has no value (level 0) #1061

Merged
merged 1 commit into from Mar 13, 2019

Conversation

clarkdave
Copy link
Contributor

The tokenizer will parse a property like width: ;, but the property helper for level 0 was not accounting for properties without a value and would throw a TypeError if the value was missing.

For example, the following would throw an unhandled error:

const CleanCSS = require('clean-css')
const cleanCss = new CleanCSS({ level: 0 })

cleanCss.minify('a{color:#f00;font-weight:;background:red}')
// TypeError: Cannot read property '0' of undefined
//   at property (./clean-css/lib/writer/helpers.js:80:33)

With this change, the property helper now checks for a missing property value before trying to access it.

The tokenizer will parse a property like `width: ;`, but the property
helper for level 0 (i.e. minification only) was not accounting for
properties without a value and would throw a TypeError if the value
was missing

With this change, the property helper now checks for a missing property
value before trying to access it
@jakubpawlowicz
Copy link
Collaborator

Good stuff @clarkdave, I'm gonna merge it.

@clarkdave
Copy link
Contributor Author

Thanks @jakubpawlowicz !

@jakubpawlowicz jakubpawlowicz merged commit dc728a8 into clean-css:master Mar 13, 2019
jakubpawlowicz pushed a commit that referenced this pull request Jan 25, 2020
The tokenizer will parse a property like `width: ;`, but the property
helper for level 0 (i.e. minification only) was not accounting for
properties without a value and would throw a TypeError if the value
was missing

With this change, the property helper now checks for a missing property
value before trying to access it
@clarkdave clarkdave deleted the loyaltylion/fixes branch June 1, 2020 20:01
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.

None yet

2 participants