Skip to content

Fix calc being partially matched to a different function signature #31

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ test(
'2px'
)

test(
'should not match "calc" in another function signature',
testFixture,
'-calc(1px + 1px)',
)

test(
'should discard zero values (#2) (1)',
testFixture,
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { parser } from './parser' // eslint-disable-line
import reducer from './lib/reducer'
import stringifier from './lib/stringifier'

const MATCH_CALC = /((?:\-[a-z]+\-)?calc)/
const MATCH_CALC = /^((?:\-[a-z]+\-)?calc)$/

export default (value, precision = 5) => {
return valueParser(value).walk(node => {
Expand Down