From: Jakub Pawlowicz Date: Sat, 7 Jun 2014 21:14:09 +0000 (+0100) Subject: Fixes #288 - adds smarter expression parsing. X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=0a2a0cf198d0d0ac9774f8e2c162251006a0e7c0;p=clean-css.git Fixes #288 - adds smarter expression parsing. --- diff --git a/History.md b/History.md index 9171db5f..c2d1057e 100644 --- a/History.md +++ b/History.md @@ -19,6 +19,7 @@ * Fixed issue [#257](https://github.com/GoalSmashers/clean-css/issues/257) - turns hsla/rgba to transparent if possible. * Fixed issue [#265](https://github.com/GoalSmashers/clean-css/issues/265) - adds support for multiple input files. * Fixed issue [#275](https://github.com/GoalSmashers/clean-css/issues/275) - handling transform properties. +* Fixed issue [#288](https://github.com/GoalSmashers/clean-css/issues/288) - adds smarter expression parsing. [2.1.8 / 2014-03-28](https://github.com/GoalSmashers/clean-css/compare/v2.1.7...v2.1.8) ================== diff --git a/lib/text/expressions.js b/lib/text/expressions.js index da1f52e3..b231d85f 100644 --- a/lib/text/expressions.js +++ b/lib/text/expressions.js @@ -26,8 +26,12 @@ module.exports = function Expressions() { } } - if (level === 0 || !next) + if (level === 0 && next == ')') break; + if (!next) { + end = data.substring(0, end).lastIndexOf('}'); + break; + } } return end; diff --git a/test/unit-test.js b/test/unit-test.js index 623c8534..3d129da7 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -330,7 +330,8 @@ vows.describe('clean-units').addBatch({ 'in comment': "/*! expression(this.runtimeStyle['zoom']) */", 'complex': 'a{width:expression((this.parentNode.innerWidth + this.parentNode.innerHeight) / 2 )}', 'with parentheses': "a{width:expression(this.parentNode.innerText == ')' ? '5px' : '10px' )}", - 'open ended (broken)': "a{width:expression(this.parentNode.innerText == }" + 'open ended (broken)': "a{width:expression(this.parentNode.innerText == }", + 'function call & advanced': 'a{zoom:expression(function(el){el.style.zoom="1"}(this))}' }), 'text content': cssContext({ 'normal #1': 'a{content:"."}',