Skip to content

Commit 9ccbed7

Browse files
committed
Allow leading semicolon in front of properties
1 parent c0fce79 commit 9ccbed7

File tree

8 files changed

+45
-15
lines changed

8 files changed

+45
-15
lines changed

build/node-parserlib.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
THE SOFTWARE.
2222
2323
*/
24-
/* Version v@VERSION@, Build time: 2-March-2012 02:36:35 */
24+
/* Version v@VERSION@, Build time: 2-March-2012 02:42:45 */
2525
var parserlib = {};
2626
(function(){
2727

@@ -926,7 +926,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
926926
THE SOFTWARE.
927927
928928
*/
929-
/* Version v@VERSION@, Build time: 2-March-2012 02:36:35 */
929+
/* Version v@VERSION@, Build time: 2-March-2012 02:42:45 */
930930
(function(){
931931
var EventTarget = parserlib.util.EventTarget,
932932
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -3170,7 +3170,7 @@ Parser.prototype = function(){
31703170

31713171
while(true){
31723172

3173-
if (readMargins && this._margin()){
3173+
if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){
31743174
//noop
31753175
} else if (this._declaration()){
31763176
if (!tokenStream.match(Tokens.SEMICOLON)){

build/npm/lib/node-parserlib.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
THE SOFTWARE.
2222
2323
*/
24-
/* Version v@VERSION@, Build time: 2-March-2012 02:36:35 */
24+
/* Version v@VERSION@, Build time: 2-March-2012 02:42:45 */
2525
var parserlib = {};
2626
(function(){
2727

@@ -926,7 +926,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
926926
THE SOFTWARE.
927927
928928
*/
929-
/* Version v@VERSION@, Build time: 2-March-2012 02:36:35 */
929+
/* Version v@VERSION@, Build time: 2-March-2012 02:42:45 */
930930
(function(){
931931
var EventTarget = parserlib.util.EventTarget,
932932
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -3170,7 +3170,7 @@ Parser.prototype = function(){
31703170

31713171
while(true){
31723172

3173-
if (readMargins && this._margin()){
3173+
if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){
31743174
//noop
31753175
} else if (this._declaration()){
31763176
if (!tokenStream.match(Tokens.SEMICOLON)){

build/parserlib-core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
THE SOFTWARE.
2222
2323
*/
24-
/* Version v@VERSION@, Build time: 2-March-2012 02:36:35 */
24+
/* Version v@VERSION@, Build time: 2-March-2012 02:42:45 */
2525
var parserlib = {};
2626
(function(){
2727

build/parserlib-css.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
THE SOFTWARE.
2222
2323
*/
24-
/* Version v@VERSION@, Build time: 2-March-2012 02:36:35 */
24+
/* Version v@VERSION@, Build time: 2-March-2012 02:42:45 */
2525
(function(){
2626
var EventTarget = parserlib.util.EventTarget,
2727
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2265,7 +2265,7 @@ Parser.prototype = function(){
22652265

22662266
while(true){
22672267

2268-
if (readMargins && this._margin()){
2268+
if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){
22692269
//noop
22702270
} else if (this._declaration()){
22712271
if (!tokenStream.match(Tokens.SEMICOLON)){

build/parserlib-tests.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,22 @@
15061506
Assert.isTrue(event.important, "Important should be true.");
15071507
});
15081508
var result = parser.parse(".foo {\n color: #fff !important;\n}");
1509-
}
1509+
},
1510+
1511+
"Test rule with leading semicolon": function(){
1512+
var parser = new Parser({ strict: true});
1513+
parser.addListener("property", function(event){
1514+
Assert.areEqual("color", event.property.toString());
1515+
Assert.areEqual("#fff", event.value.toString());
1516+
Assert.areEqual(5, event.property.col, "Property column should be 5.");
1517+
Assert.areEqual(2, event.property.line, "Property line should be 2.");
1518+
Assert.areEqual(5, event.col, "Event column should be 5.");
1519+
Assert.areEqual(2, event.line, "Event line should be 2.");
1520+
Assert.areEqual(12, event.value.parts[0].col, "First part column should be 12.");
1521+
Assert.areEqual(2, event.value.parts[0].line, "First part line should be 2.");
1522+
});
1523+
var result = parser.parse(".foo {\n; color: #fff;\n}");
1524+
}
15101525
}));
15111526

15121527

build/parserlib.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
THE SOFTWARE.
2222
2323
*/
24-
/* Version v@VERSION@, Build time: 2-March-2012 02:36:35 */
24+
/* Version v@VERSION@, Build time: 2-March-2012 02:42:45 */
2525
var parserlib = {};
2626
(function(){
2727

@@ -926,7 +926,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
926926
THE SOFTWARE.
927927
928928
*/
929-
/* Version v@VERSION@, Build time: 2-March-2012 02:36:35 */
929+
/* Version v@VERSION@, Build time: 2-March-2012 02:42:45 */
930930
(function(){
931931
var EventTarget = parserlib.util.EventTarget,
932932
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -3170,7 +3170,7 @@ Parser.prototype = function(){
31703170

31713171
while(true){
31723172

3173-
if (readMargins && this._margin()){
3173+
if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){
31743174
//noop
31753175
} else if (this._declaration()){
31763176
if (!tokenStream.match(Tokens.SEMICOLON)){

src/css/Parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1979,7 +1979,7 @@ Parser.prototype = function(){
19791979

19801980
while(true){
19811981

1982-
if (readMargins && this._margin()){
1982+
if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){
19831983
//noop
19841984
} else if (this._declaration()){
19851985
if (!tokenStream.match(Tokens.SEMICOLON)){

tests/css/Parser.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,22 @@
15061506
Assert.isTrue(event.important, "Important should be true.");
15071507
});
15081508
var result = parser.parse(".foo {\n color: #fff !important;\n}");
1509-
}
1509+
},
1510+
1511+
"Test rule with leading semicolon": function(){
1512+
var parser = new Parser({ strict: true});
1513+
parser.addListener("property", function(event){
1514+
Assert.areEqual("color", event.property.toString());
1515+
Assert.areEqual("#fff", event.value.toString());
1516+
Assert.areEqual(5, event.property.col, "Property column should be 5.");
1517+
Assert.areEqual(2, event.property.line, "Property line should be 2.");
1518+
Assert.areEqual(5, event.col, "Event column should be 5.");
1519+
Assert.areEqual(2, event.line, "Event line should be 2.");
1520+
Assert.areEqual(12, event.value.parts[0].col, "First part column should be 12.");
1521+
Assert.areEqual(2, event.value.parts[0].line, "First part line should be 2.");
1522+
});
1523+
var result = parser.parse(".foo {\n; color: #fff;\n}");
1524+
}
15101525
}));
15111526

15121527

0 commit comments

Comments
 (0)