Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

made accidental css nesting detectable (a { p { ...) #35

Merged
merged 3 commits into from May 15, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions slowparse.js
Expand Up @@ -751,9 +751,15 @@ var Slowparse = (function() {
}

var next = this.stream.next(),
errorMsg = "[_parseProperty] Expected }, <, ; or :, " +
errorMsg = "[_parseProperty] Expected }, {, <, ; or :, " +
"instead found " + next;

if (next === '{') {
throw new ParseError("MISSING_CSS_BLOCK_CLOSER", this, selectorStart,
propertyStart, selector);
}


if ((this.stream.end() && next !== ':') || next === '<' ||
next === '}') {
throw new ParseError("UNFINISHED_CSS_PROPERTY", this, propertyStart,
Expand Down Expand Up @@ -789,10 +795,6 @@ var Slowparse = (function() {
throw new ParseError("MISSING_CSS_VALUE", this, propertyStart,
propertyEnd, property);
}
else if (next === '{') {
throw new ParseError("MISSING_CSS_BLOCK_CLOSER", this, selectorStart,
propertyStart, selector);
}
else {
throw new ParseError("UNCAUGHT_CSS_PARSE_ERROR", this,
token.interval.start, token.interval.end,
Expand Down
21 changes: 21 additions & 0 deletions spec/index.html
Expand Up @@ -71,6 +71,12 @@
color: inherit;
}

.test {
margin-top: 3em;
border-left: 1px solid black;
padding-left: 0.5em;
}

.test.failed, .test.failed .html {
background: firebrick;
}
Expand Down Expand Up @@ -483,6 +489,21 @@ <h1 class="error-category">CSS Errors</h1>
}
</script>
</div>
<div class="test">
<script type="text/x-bad-html">
<style> a { li {
</script>
<script type="application/json">
{
"type": "MISSING_CSS_BLOCK_CLOSER",
"cssValue": {
"start": 8,
"end": 12,
"value": "a"
}
}
</script>
</div>
<div class="test">
<script type="text/x-bad-html">
<style> /* unterminated comment
Expand Down