Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed YUI Test issues, bumped version

  • Loading branch information...
commit 80f795cb35f2fc144757f67c4d2fccdd7e28c347 1 parent 036bd12
@nzakas nzakas authored
View
16 CHANGELOG
@@ -1,3 +1,17 @@
+November 13, 2012 - v0.2.0
+
+* Merge pull request #36 from mattiacci/border-radius (Nicholas C. Zakas)
+* Fix validation of border-radius (Michael Mattiacci)
+* Merge pull request #33 from mattiacci/bg-position (Nicholas C. Zakas)
+* Fix validation of background-position (Michael Mattiacci)
+* Merge pull request #31 from nightwing/master (Nicholas C. Zakas)
+* fix typo (nightwing)
+* v0.1.9 (Nicholas C. Zakas)
+* Expose vendor prefix for @keyframes (fixes #29) (Nicholas C. Zakas)
+* Add support for o-keyframes and remove ms-keyframes (Nicholas C. Zakas)
+* Fix changelog (Nicholas C. Zakas)
+
+
July 23, 2012 - v0.1.9
* Expose vendor prefix for @keyframes (fixes #29) (Nicholas C. Zakas)
@@ -253,3 +267,5 @@ November 28, 2011 - v0.1.0
+
+
View
104 build.xml
@@ -1,31 +1,31 @@
<project name="parserlib" default="build.all">
<!-- version number -->
- <property name="parserlib.version" value="0.1.9" />
+ <property name="parserlib.version" value="0.2.0" />
<!-- the directories containing the source files -->
<property name="src.dir" value="./src" />
<property name="tests.dir" value="./tests" />
<property name="npm.dir" value="./npm" />
-
+
<!-- the directories and files to output to -->
<property name="lib.dir" value="./lib" />
-
+
<!-- the directories and files to output to -->
<property name="build.dir" value="./build" />
<property name="release.dir" value="./release" />
<property name="build.npm.dir" value="${build.dir}/npm" />
-
+
<!-- output filenames -->
<property name="full.build.file" value="parserlib.js"/>
<property name="core.build.file" value="parserlib-core.js"/>
<property name="css.build.file" value="parserlib-css.js"/>
<property name="tests.build.file" value="parserlib-tests.js"/>
<property name="node.build.file" value="node-parserlib.js"/>
-
+
<!-- license information -->
<loadfile property="license.text" srcfile="LICENSE" />
-
+
<tstamp>
<format property="RIGHT_NOW"
pattern="d-MMMM-yyyy hh:mm:ss"
@@ -35,57 +35,57 @@
<format property="SIMPLE_DATE"
pattern="MMMM d, yyyy"
locale="en,US"/>
- </tstamp>
-
+ </tstamp>
+
<!-- clean -->
<target name="clean">
<delete dir="${build.dir}" />
</target>
-
+
<target name="changelog.update">
<exec executable="git" failonerror="true" outputproperty="git.tag">
<arg line="tag"/>
- </exec>
+ </exec>
<script language="javascript"><![CDATA[
//get the most recent tag to get the diff
var tags = parserlib.getProperty("git.tag").replace("\r", "").split("\n"),
lastTag = tags[tags.length-1];
parserlib.setProperty("git.log.range", lastTag + "..HEAD");
]]></script>
-
+
<!-- git log -pretty=format:'* %s (%an)' v0.4.0..v0.5.0-->
<exec executable="git" failonerror="true" outputproperty="git.changelog">
<arg line="log --pretty=format:'* %s (%an)' ${git.log.range}"/>
- </exec>
-
+ </exec>
+
<concat destfile="CHANGELOG.tmp" fixlastline="true">
<header trimleading="yes">${SIMPLE_DATE} - v${parserlib.version}
-
+
${git.changelog}
-
+
</header>
<fileset dir="." includes="CHANGELOG" />
</concat>
-
+
<delete file="CHANGELOG"/>
<move file="CHANGELOG.tmp" tofile="CHANGELOG"/>
-
+
</target>
-
+
<!-- validate JS files with JSHint -->
- <target name="lint">
+ <target name="lint">
<fileset dir="${src.dir}" includes="**/*.js" id="jsfiles.raw"/>
<pathconvert pathsep=" " property="jsfiles.clean" refid="jsfiles.raw" />
<exec executable="java" failonerror="true">
<arg line="-jar"/>
<arg path="${lib.dir}/js.jar"/>
- <arg path="${lib.dir}/jshint.js" />
+ <arg path="${lib.dir}/jshint.js" />
<arg line="${jsfiles.clean} curly=true,forin=true,latedef=true,evil=true,loopfunc=true,undef=true,rhino=false" />
- </exec>
- </target>
-
+ </exec>
+ </target>
+
<!-- run tests on the command line -->
- <target name="test" depends="lint,build.all">
+ <target name="test" depends="lint,build.all">
<apply executable="java" failonerror="true">
<fileset dir="${tests.dir}" includes="**/*.js"/>
<arg line="-jar"/>
@@ -93,19 +93,19 @@
<arg path="${lib.dir}/yuitest-rhino-cli.js" />
<arg path="${build.dir}/${full.build.file}" />
<srcfile/>
- </apply>
- </target>
-
+ </apply>
+ </target>
+
<!-- build the full library -->
<target name="build.full" depends="build.core,build.css">
<concat destfile="${build.dir}/${full.build.file}" fixlastline="true">
<filelist dir="${build.dir}" files="${core.build.file}, ${css.build.file}"/>
- </concat>
+ </concat>
</target>
-
+
<!-- build the core library -->
<target name="build.core">
-
+
<concat destfile="${build.dir}/${core.build.file}" fixlastline="true">
<header trimleading="yes">/*!
${license.text}
@@ -127,13 +127,13 @@
})();
</footer>
</concat>
-
+
</target>
-
+
<!-- build the CSS library -->
<target name="build.css">
<concat destfile="${build.dir}/${css.build.file}" fixlastline="true">
- <header trimleading="yes">/*
+ <header trimleading="yes">/*
${license.text}
*/
/* Version v@VERSION@, Build time: ${RIGHT_NOW} */
@@ -143,13 +143,13 @@
StringReader = parserlib.util.StringReader,
SyntaxError = parserlib.util.SyntaxError,
SyntaxUnit = parserlib.util.SyntaxUnit;
- </header>
+ </header>
<!--<filelist dir="${src.dir}/css" files="CSSTokens.js, CSSSelectorUnit.js, CSSColors.js, CSSValueUnit.js, CSSParser.js"/>-->
<fileset dir="${src.dir}/css" includes="*.js" />
<footer trimleading="yes">
parserlib.css = {
- Colors :Colors,
- Combinator :Combinator,
+ Colors :Colors,
+ Combinator :Combinator,
Parser :Parser,
PropertyName :PropertyName,
PropertyValue :PropertyValue,
@@ -168,39 +168,39 @@
</footer>
</concat>
-
+
</target>
-
+
<!-- build the Node.js package -->
<target name="build.node">
-
+
<concat destfile="${build.dir}/${node.build.file}" fixlastline="true">
<filelist dir="${build.dir}" files="${core.build.file}, ${css.build.file}"/>
<footer trimleading="yes">
(function(){
for(var prop in parserlib){
- exports[prop] = parserlib[prop];
+ exports[prop] = parserlib[prop];
}
})();
</footer>
</concat>
-
+
<mkdir dir="${build.npm.dir}"/>
<mkdir dir="${build.npm.dir}/lib"/>
<copy file="${npm.dir}/package.json" todir="${build.npm.dir}"/>
<copy file="${build.dir}/${node.build.file}" todir="${build.npm.dir}/lib"/>
-
+
<!-- CRLF will cause Node version to break -->
<fixcrlf srcdir="${build.dir}" includes="**/*" eol="lf" />
- </target>
-
+ </target>
+
<!-- build the tests into a single file -->
- <target name="build.tests">
+ <target name="build.tests">
<concat destfile="${build.dir}/${tests.build.file}" fixlastline="true">
- <fileset dir="${tests.dir}/" includes="**/*.js" />
- </concat>
- </target>
-
+ <fileset dir="${tests.dir}/" includes="**/*.js" />
+ </concat>
+ </target>
+
<!-- Create a release with version number embedded -->
<target name="release" depends="test,build.all,changelog.update">
<delete dir="${release.dir}" />
@@ -210,9 +210,9 @@
</copy>
<replaceregexp match="@VERSION@" replace="${parserlib.version}" flags="g" byline="true">
<fileset dir="${release.dir}" includes="**/*"/>
- </replaceregexp>
- </target>
-
+ </replaceregexp>
+ </target>
+
<!-- Build all files -->
<target name="build.all" depends="build.full,build.node,build.tests"/>
View
95 build/node-parserlib.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v@VERSION@, Build time: 23-July-2012 10:52:31 */
+/* Version v@VERSION@, Build time: 13-November-2012 01:17:54 */
var parserlib = {};
(function(){
@@ -908,7 +908,7 @@ TokenStreamBase : TokenStreamBase
})();
-/*
+/*
Parser-Lib
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v@VERSION@, Build time: 23-July-2012 10:52:31 */
+/* Version v@VERSION@, Build time: 13-November-2012 01:17:54 */
(function(){
var EventTarget = parserlib.util.EventTarget,
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2145,7 +2145,7 @@ Parser.prototype = function(){
//there must be a next selector
if (nextSelector === null){
- this._unexpectedToken(this.LT(1));
+ this._unexpectedToken(tokenStream.LT(1));
} else {
//nextSelector is an instance of SelectorPart
@@ -3597,7 +3597,7 @@ var Properties = {
valid = ValidationTypes.isAny(expression, numeric);
if (!valid) {
- if (expression.peek() == "/" && count > 1 && !slash) {
+ if (expression.peek() == "/" && count > 0 && !slash) {
slash = true;
max = count + 5;
expression.next();
@@ -5980,7 +5980,7 @@ var ValidationTypes = {
},
/**
- * Determines if the next part(s) of the given expresion
+ * Determines if the next part(s) of the given expression
* are one of a group.
*/
isAnyOfGroup: function(expression, types) {
@@ -6127,10 +6127,16 @@ var ValidationTypes = {
var types = this,
result = false,
numeric = "<percentage> | <length>",
- xDir = "left | center | right",
- yDir = "top | center | bottom",
- part,
- i, len;
+ xDir = "left | right",
+ yDir = "top | bottom",
+ count = 0,
+ hasNext = function() {
+ return expression.hasNext() && expression.peek() != ",";
+ };
+
+ while (expression.peek(count) && expression.peek(count) != ",") {
+ count++;
+ }
/*
<position> = [
@@ -6142,40 +6148,48 @@ var ValidationTypes = {
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]
+*/
-*/
-
- if (ValidationTypes.isAny(expression, "top | bottom")) {
- result = true;
+ if (count < 3) {
+ if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
+ result = true;
+ ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, xDir + " | center");
+ }
} else {
-
- //must be two-part
- if (ValidationTypes.isAny(expression, numeric)){
- if (expression.hasNext()){
- result = ValidationTypes.isAny(expression, numeric + " | " + yDir);
- }
- } else if (ValidationTypes.isAny(expression, xDir)){
- if (expression.hasNext()){
-
- //two- or three-part
- if (ValidationTypes.isAny(expression, yDir)){
+ if (ValidationTypes.isAny(expression, xDir)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
result = true;
-
ValidationTypes.isAny(expression, numeric);
-
- } else if (ValidationTypes.isAny(expression, numeric)){
-
- //could also be two-part, so check the next part
- if (ValidationTypes.isAny(expression, yDir)){
- ValidationTypes.isAny(expression, numeric);
- }
-
+ } else if (ValidationTypes.isAny(expression, "center")) {
result = true;
}
}
- }
- }
-
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ result = true;
+ }
+ }
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ }
+ }
+ }
return result;
},
@@ -6282,9 +6296,10 @@ var ValidationTypes = {
};
+
parserlib.css = {
-Colors :Colors,
-Combinator :Combinator,
+Colors :Colors,
+Combinator :Combinator,
Parser :Parser,
PropertyName :PropertyName,
PropertyValue :PropertyValue,
@@ -6306,7 +6321,7 @@ ValidationError :ValidationError
(function(){
for(var prop in parserlib){
-exports[prop] = parserlib[prop];
+exports[prop] = parserlib[prop];
}
})();
View
95 build/npm/lib/node-parserlib.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v@VERSION@, Build time: 23-July-2012 10:52:31 */
+/* Version v@VERSION@, Build time: 13-November-2012 01:17:54 */
var parserlib = {};
(function(){
@@ -908,7 +908,7 @@ TokenStreamBase : TokenStreamBase
})();
-/*
+/*
Parser-Lib
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v@VERSION@, Build time: 23-July-2012 10:52:31 */
+/* Version v@VERSION@, Build time: 13-November-2012 01:17:54 */
(function(){
var EventTarget = parserlib.util.EventTarget,
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2145,7 +2145,7 @@ Parser.prototype = function(){
//there must be a next selector
if (nextSelector === null){
- this._unexpectedToken(this.LT(1));
+ this._unexpectedToken(tokenStream.LT(1));
} else {
//nextSelector is an instance of SelectorPart
@@ -3597,7 +3597,7 @@ var Properties = {
valid = ValidationTypes.isAny(expression, numeric);
if (!valid) {
- if (expression.peek() == "/" && count > 1 && !slash) {
+ if (expression.peek() == "/" && count > 0 && !slash) {
slash = true;
max = count + 5;
expression.next();
@@ -5980,7 +5980,7 @@ var ValidationTypes = {
},
/**
- * Determines if the next part(s) of the given expresion
+ * Determines if the next part(s) of the given expression
* are one of a group.
*/
isAnyOfGroup: function(expression, types) {
@@ -6127,10 +6127,16 @@ var ValidationTypes = {
var types = this,
result = false,
numeric = "<percentage> | <length>",
- xDir = "left | center | right",
- yDir = "top | center | bottom",
- part,
- i, len;
+ xDir = "left | right",
+ yDir = "top | bottom",
+ count = 0,
+ hasNext = function() {
+ return expression.hasNext() && expression.peek() != ",";
+ };
+
+ while (expression.peek(count) && expression.peek(count) != ",") {
+ count++;
+ }
/*
<position> = [
@@ -6142,40 +6148,48 @@ var ValidationTypes = {
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]
+*/
-*/
-
- if (ValidationTypes.isAny(expression, "top | bottom")) {
- result = true;
+ if (count < 3) {
+ if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
+ result = true;
+ ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, xDir + " | center");
+ }
} else {
-
- //must be two-part
- if (ValidationTypes.isAny(expression, numeric)){
- if (expression.hasNext()){
- result = ValidationTypes.isAny(expression, numeric + " | " + yDir);
- }
- } else if (ValidationTypes.isAny(expression, xDir)){
- if (expression.hasNext()){
-
- //two- or three-part
- if (ValidationTypes.isAny(expression, yDir)){
+ if (ValidationTypes.isAny(expression, xDir)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
result = true;
-
ValidationTypes.isAny(expression, numeric);
-
- } else if (ValidationTypes.isAny(expression, numeric)){
-
- //could also be two-part, so check the next part
- if (ValidationTypes.isAny(expression, yDir)){
- ValidationTypes.isAny(expression, numeric);
- }
-
+ } else if (ValidationTypes.isAny(expression, "center")) {
result = true;
}
}
- }
- }
-
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ result = true;
+ }
+ }
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ }
+ }
+ }
return result;
},
@@ -6282,9 +6296,10 @@ var ValidationTypes = {
};
+
parserlib.css = {
-Colors :Colors,
-Combinator :Combinator,
+Colors :Colors,
+Combinator :Combinator,
Parser :Parser,
PropertyName :PropertyName,
PropertyValue :PropertyValue,
@@ -6306,7 +6321,7 @@ ValidationError :ValidationError
(function(){
for(var prop in parserlib){
-exports[prop] = parserlib[prop];
+exports[prop] = parserlib[prop];
}
})();
View
2  build/parserlib-core.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v@VERSION@, Build time: 23-July-2012 10:52:31 */
+/* Version v@VERSION@, Build time: 13-November-2012 01:17:54 */
var parserlib = {};
(function(){
View
91 build/parserlib-css.js
@@ -1,4 +1,4 @@
-/*
+/*
Parser-Lib
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v@VERSION@, Build time: 23-July-2012 10:52:31 */
+/* Version v@VERSION@, Build time: 13-November-2012 01:17:54 */
(function(){
var EventTarget = parserlib.util.EventTarget,
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -1235,7 +1235,7 @@ Parser.prototype = function(){
//there must be a next selector
if (nextSelector === null){
- this._unexpectedToken(this.LT(1));
+ this._unexpectedToken(tokenStream.LT(1));
} else {
//nextSelector is an instance of SelectorPart
@@ -2687,7 +2687,7 @@ var Properties = {
valid = ValidationTypes.isAny(expression, numeric);
if (!valid) {
- if (expression.peek() == "/" && count > 1 && !slash) {
+ if (expression.peek() == "/" && count > 0 && !slash) {
slash = true;
max = count + 5;
expression.next();
@@ -5070,7 +5070,7 @@ var ValidationTypes = {
},
/**
- * Determines if the next part(s) of the given expresion
+ * Determines if the next part(s) of the given expression
* are one of a group.
*/
isAnyOfGroup: function(expression, types) {
@@ -5217,10 +5217,16 @@ var ValidationTypes = {
var types = this,
result = false,
numeric = "<percentage> | <length>",
- xDir = "left | center | right",
- yDir = "top | center | bottom",
- part,
- i, len;
+ xDir = "left | right",
+ yDir = "top | bottom",
+ count = 0,
+ hasNext = function() {
+ return expression.hasNext() && expression.peek() != ",";
+ };
+
+ while (expression.peek(count) && expression.peek(count) != ",") {
+ count++;
+ }
/*
<position> = [
@@ -5232,40 +5238,48 @@ var ValidationTypes = {
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]
+*/
-*/
-
- if (ValidationTypes.isAny(expression, "top | bottom")) {
- result = true;
+ if (count < 3) {
+ if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
+ result = true;
+ ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, xDir + " | center");
+ }
} else {
-
- //must be two-part
- if (ValidationTypes.isAny(expression, numeric)){
- if (expression.hasNext()){
- result = ValidationTypes.isAny(expression, numeric + " | " + yDir);
- }
- } else if (ValidationTypes.isAny(expression, xDir)){
- if (expression.hasNext()){
-
- //two- or three-part
- if (ValidationTypes.isAny(expression, yDir)){
+ if (ValidationTypes.isAny(expression, xDir)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
result = true;
-
ValidationTypes.isAny(expression, numeric);
-
- } else if (ValidationTypes.isAny(expression, numeric)){
-
- //could also be two-part, so check the next part
- if (ValidationTypes.isAny(expression, yDir)){
- ValidationTypes.isAny(expression, numeric);
- }
-
+ } else if (ValidationTypes.isAny(expression, "center")) {
result = true;
}
}
- }
- }
-
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ result = true;
+ }
+ }
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ }
+ }
+ }
return result;
},
@@ -5372,9 +5386,10 @@ var ValidationTypes = {
};
+
parserlib.css = {
-Colors :Colors,
-Combinator :Combinator,
+Colors :Colors,
+Combinator :Combinator,
Parser :Parser,
PropertyName :PropertyName,
PropertyValue :PropertyValue,
View
32 build/parserlib-tests.js
@@ -1548,6 +1548,22 @@
var result = parser.parse(".foo {\n; color: #fff;\n}");
}
}));
+
+ suite.add(new YUITest.TestCase({
+
+ name: "Invalid CSS Parsing Tests",
+
+ "Test parsing invalid celector": function(){
+ var error;
+ var parser = new Parser();
+ parser.addListener("error", function(e){error = e});
+ parser.parse("c++{}");
+
+ Assert.areEqual("error", error.type);
+ Assert.areEqual(1, error.line);
+ Assert.areEqual(3, error.col);
+ }
+ }));
YUITest.TestRunner.add(suite);
@@ -2411,23 +2427,28 @@
"top",
"bottom",
"center",
+ "100%",
"left center",
+ "bottom left",
"left 10px",
"center bottom",
"10% top",
"left 10px bottom",
"right top 5%",
- "center 3em center 10%",
+ "top 3em center",
+ "center top 3em",
+ "top 3em right 10%",
"top, bottom",
"left 10px, left 10px",
"right top 5%, left 10px bottom"
],
invalid: {
- "foo" : "Expected (<bg-position>) but found 'foo'.",
- "left center right" : "Expected end of value but found 'right'."
-
- }
+ "foo" : "Expected (<bg-position>) but found 'foo'.",
+ "10% left" : "Expected end of value but found 'left'.",
+ "left center right" : "Expected end of value but found 'center'.",
+ "center 3em right 10%": "Expected end of value but found '3em'.",
+ }
}));
suite.add(new ValidationTestCase({
@@ -2569,6 +2590,7 @@
"5px",
"25%",
"5px 25%",
+ "5px / 25%",
"5px 25% / 7px 27%",
"1px 2px 3px 4px / 5px 6px 7px 8px"
],
View
93 build/parserlib.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v@VERSION@, Build time: 23-July-2012 10:52:31 */
+/* Version v@VERSION@, Build time: 13-November-2012 01:17:54 */
var parserlib = {};
(function(){
@@ -908,7 +908,7 @@ TokenStreamBase : TokenStreamBase
})();
-/*
+/*
Parser-Lib
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v@VERSION@, Build time: 23-July-2012 10:52:31 */
+/* Version v@VERSION@, Build time: 13-November-2012 01:17:54 */
(function(){
var EventTarget = parserlib.util.EventTarget,
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2145,7 +2145,7 @@ Parser.prototype = function(){
//there must be a next selector
if (nextSelector === null){
- this._unexpectedToken(this.LT(1));
+ this._unexpectedToken(tokenStream.LT(1));
} else {
//nextSelector is an instance of SelectorPart
@@ -3597,7 +3597,7 @@ var Properties = {
valid = ValidationTypes.isAny(expression, numeric);
if (!valid) {
- if (expression.peek() == "/" && count > 1 && !slash) {
+ if (expression.peek() == "/" && count > 0 && !slash) {
slash = true;
max = count + 5;
expression.next();
@@ -5980,7 +5980,7 @@ var ValidationTypes = {
},
/**
- * Determines if the next part(s) of the given expresion
+ * Determines if the next part(s) of the given expression
* are one of a group.
*/
isAnyOfGroup: function(expression, types) {
@@ -6127,10 +6127,16 @@ var ValidationTypes = {
var types = this,
result = false,
numeric = "<percentage> | <length>",
- xDir = "left | center | right",
- yDir = "top | center | bottom",
- part,
- i, len;
+ xDir = "left | right",
+ yDir = "top | bottom",
+ count = 0,
+ hasNext = function() {
+ return expression.hasNext() && expression.peek() != ",";
+ };
+
+ while (expression.peek(count) && expression.peek(count) != ",") {
+ count++;
+ }
/*
<position> = [
@@ -6142,40 +6148,48 @@ var ValidationTypes = {
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]
+*/
-*/
-
- if (ValidationTypes.isAny(expression, "top | bottom")) {
- result = true;
+ if (count < 3) {
+ if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
+ result = true;
+ ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, xDir + " | center");
+ }
} else {
-
- //must be two-part
- if (ValidationTypes.isAny(expression, numeric)){
- if (expression.hasNext()){
- result = ValidationTypes.isAny(expression, numeric + " | " + yDir);
- }
- } else if (ValidationTypes.isAny(expression, xDir)){
- if (expression.hasNext()){
-
- //two- or three-part
- if (ValidationTypes.isAny(expression, yDir)){
+ if (ValidationTypes.isAny(expression, xDir)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
result = true;
-
ValidationTypes.isAny(expression, numeric);
-
- } else if (ValidationTypes.isAny(expression, numeric)){
-
- //could also be two-part, so check the next part
- if (ValidationTypes.isAny(expression, yDir)){
- ValidationTypes.isAny(expression, numeric);
- }
-
+ } else if (ValidationTypes.isAny(expression, "center")) {
result = true;
}
}
- }
- }
-
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ result = true;
+ }
+ }
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ }
+ }
+ }
return result;
},
@@ -6282,9 +6296,10 @@ var ValidationTypes = {
};
+
parserlib.css = {
-Colors :Colors,
-Combinator :Combinator,
+Colors :Colors,
+Combinator :Combinator,
Parser :Parser,
PropertyName :PropertyName,
PropertyValue :PropertyValue,
View
1,240 lib/yuitest-rhino-cli.js
622 additions, 618 deletions not shown
View
95 release/node-parserlib.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v0.1.9, Build time: 23-July-2012 10:52:31 */
+/* Version v0.2.0, Build time: 13-November-2012 01:17:54 */
var parserlib = {};
(function(){
@@ -908,7 +908,7 @@ TokenStreamBase : TokenStreamBase
})();
-/*
+/*
Parser-Lib
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v0.1.9, Build time: 23-July-2012 10:52:31 */
+/* Version v0.2.0, Build time: 13-November-2012 01:17:54 */
(function(){
var EventTarget = parserlib.util.EventTarget,
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2145,7 +2145,7 @@ Parser.prototype = function(){
//there must be a next selector
if (nextSelector === null){
- this._unexpectedToken(this.LT(1));
+ this._unexpectedToken(tokenStream.LT(1));
} else {
//nextSelector is an instance of SelectorPart
@@ -3597,7 +3597,7 @@ var Properties = {
valid = ValidationTypes.isAny(expression, numeric);
if (!valid) {
- if (expression.peek() == "/" && count > 1 && !slash) {
+ if (expression.peek() == "/" && count > 0 && !slash) {
slash = true;
max = count + 5;
expression.next();
@@ -5980,7 +5980,7 @@ var ValidationTypes = {
},
/**
- * Determines if the next part(s) of the given expresion
+ * Determines if the next part(s) of the given expression
* are one of a group.
*/
isAnyOfGroup: function(expression, types) {
@@ -6127,10 +6127,16 @@ var ValidationTypes = {
var types = this,
result = false,
numeric = "<percentage> | <length>",
- xDir = "left | center | right",
- yDir = "top | center | bottom",
- part,
- i, len;
+ xDir = "left | right",
+ yDir = "top | bottom",
+ count = 0,
+ hasNext = function() {
+ return expression.hasNext() && expression.peek() != ",";
+ };
+
+ while (expression.peek(count) && expression.peek(count) != ",") {
+ count++;
+ }
/*
<position> = [
@@ -6142,40 +6148,48 @@ var ValidationTypes = {
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]
+*/
-*/
-
- if (ValidationTypes.isAny(expression, "top | bottom")) {
- result = true;
+ if (count < 3) {
+ if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
+ result = true;
+ ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, xDir + " | center");
+ }
} else {
-
- //must be two-part
- if (ValidationTypes.isAny(expression, numeric)){
- if (expression.hasNext()){
- result = ValidationTypes.isAny(expression, numeric + " | " + yDir);
- }
- } else if (ValidationTypes.isAny(expression, xDir)){
- if (expression.hasNext()){
-
- //two- or three-part
- if (ValidationTypes.isAny(expression, yDir)){
+ if (ValidationTypes.isAny(expression, xDir)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
result = true;
-
ValidationTypes.isAny(expression, numeric);
-
- } else if (ValidationTypes.isAny(expression, numeric)){
-
- //could also be two-part, so check the next part
- if (ValidationTypes.isAny(expression, yDir)){
- ValidationTypes.isAny(expression, numeric);
- }
-
+ } else if (ValidationTypes.isAny(expression, "center")) {
result = true;
}
}
- }
- }
-
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ result = true;
+ }
+ }
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ }
+ }
+ }
return result;
},
@@ -6282,9 +6296,10 @@ var ValidationTypes = {
};
+
parserlib.css = {
-Colors :Colors,
-Combinator :Combinator,
+Colors :Colors,
+Combinator :Combinator,
Parser :Parser,
PropertyName :PropertyName,
PropertyValue :PropertyValue,
@@ -6306,7 +6321,7 @@ ValidationError :ValidationError
(function(){
for(var prop in parserlib){
-exports[prop] = parserlib[prop];
+exports[prop] = parserlib[prop];
}
})();
View
95 release/npm/lib/node-parserlib.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v0.1.9, Build time: 23-July-2012 10:52:31 */
+/* Version v0.2.0, Build time: 13-November-2012 01:17:54 */
var parserlib = {};
(function(){
@@ -908,7 +908,7 @@ TokenStreamBase : TokenStreamBase
})();
-/*
+/*
Parser-Lib
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v0.1.9, Build time: 23-July-2012 10:52:31 */
+/* Version v0.2.0, Build time: 13-November-2012 01:17:54 */
(function(){
var EventTarget = parserlib.util.EventTarget,
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2145,7 +2145,7 @@ Parser.prototype = function(){
//there must be a next selector
if (nextSelector === null){
- this._unexpectedToken(this.LT(1));
+ this._unexpectedToken(tokenStream.LT(1));
} else {
//nextSelector is an instance of SelectorPart
@@ -3597,7 +3597,7 @@ var Properties = {
valid = ValidationTypes.isAny(expression, numeric);
if (!valid) {
- if (expression.peek() == "/" && count > 1 && !slash) {
+ if (expression.peek() == "/" && count > 0 && !slash) {
slash = true;
max = count + 5;
expression.next();
@@ -5980,7 +5980,7 @@ var ValidationTypes = {
},
/**
- * Determines if the next part(s) of the given expresion
+ * Determines if the next part(s) of the given expression
* are one of a group.
*/
isAnyOfGroup: function(expression, types) {
@@ -6127,10 +6127,16 @@ var ValidationTypes = {
var types = this,
result = false,
numeric = "<percentage> | <length>",
- xDir = "left | center | right",
- yDir = "top | center | bottom",
- part,
- i, len;
+ xDir = "left | right",
+ yDir = "top | bottom",
+ count = 0,
+ hasNext = function() {
+ return expression.hasNext() && expression.peek() != ",";
+ };
+
+ while (expression.peek(count) && expression.peek(count) != ",") {
+ count++;
+ }
/*
<position> = [
@@ -6142,40 +6148,48 @@ var ValidationTypes = {
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]
+*/
-*/
-
- if (ValidationTypes.isAny(expression, "top | bottom")) {
- result = true;
+ if (count < 3) {
+ if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
+ result = true;
+ ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, xDir + " | center");
+ }
} else {
-
- //must be two-part
- if (ValidationTypes.isAny(expression, numeric)){
- if (expression.hasNext()){
- result = ValidationTypes.isAny(expression, numeric + " | " + yDir);
- }
- } else if (ValidationTypes.isAny(expression, xDir)){
- if (expression.hasNext()){
-
- //two- or three-part
- if (ValidationTypes.isAny(expression, yDir)){
+ if (ValidationTypes.isAny(expression, xDir)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
result = true;
-
ValidationTypes.isAny(expression, numeric);
-
- } else if (ValidationTypes.isAny(expression, numeric)){
-
- //could also be two-part, so check the next part
- if (ValidationTypes.isAny(expression, yDir)){
- ValidationTypes.isAny(expression, numeric);
- }
-
+ } else if (ValidationTypes.isAny(expression, "center")) {
result = true;
}
}
- }
- }
-
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ result = true;
+ }
+ }
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ }
+ }
+ }
return result;
},
@@ -6282,9 +6296,10 @@ var ValidationTypes = {
};
+
parserlib.css = {
-Colors :Colors,
-Combinator :Combinator,
+Colors :Colors,
+Combinator :Combinator,
Parser :Parser,
PropertyName :PropertyName,
PropertyValue :PropertyValue,
@@ -6306,7 +6321,7 @@ ValidationError :ValidationError
(function(){
for(var prop in parserlib){
-exports[prop] = parserlib[prop];
+exports[prop] = parserlib[prop];
}
})();
View
2  release/npm/package.json
@@ -1,6 +1,6 @@
{
"name": "parserlib",
- "version": "0.1.9",
+ "version": "0.2.0",
"description": "CSSLint",
"author": "Nicholas C. Zakas",
"os": ["darwin", "linux"],
View
2  release/parserlib-core.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v0.1.9, Build time: 23-July-2012 10:52:31 */
+/* Version v0.2.0, Build time: 13-November-2012 01:17:54 */
var parserlib = {};
(function(){
View
91 release/parserlib-css.js
@@ -1,4 +1,4 @@
-/*
+/*
Parser-Lib
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v0.1.9, Build time: 23-July-2012 10:52:31 */
+/* Version v0.2.0, Build time: 13-November-2012 01:17:54 */
(function(){
var EventTarget = parserlib.util.EventTarget,
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -1235,7 +1235,7 @@ Parser.prototype = function(){
//there must be a next selector
if (nextSelector === null){
- this._unexpectedToken(this.LT(1));
+ this._unexpectedToken(tokenStream.LT(1));
} else {
//nextSelector is an instance of SelectorPart
@@ -2687,7 +2687,7 @@ var Properties = {
valid = ValidationTypes.isAny(expression, numeric);
if (!valid) {
- if (expression.peek() == "/" && count > 1 && !slash) {
+ if (expression.peek() == "/" && count > 0 && !slash) {
slash = true;
max = count + 5;
expression.next();
@@ -5070,7 +5070,7 @@ var ValidationTypes = {
},
/**
- * Determines if the next part(s) of the given expresion
+ * Determines if the next part(s) of the given expression
* are one of a group.
*/
isAnyOfGroup: function(expression, types) {
@@ -5217,10 +5217,16 @@ var ValidationTypes = {
var types = this,
result = false,
numeric = "<percentage> | <length>",
- xDir = "left | center | right",
- yDir = "top | center | bottom",
- part,
- i, len;
+ xDir = "left | right",
+ yDir = "top | bottom",
+ count = 0,
+ hasNext = function() {
+ return expression.hasNext() && expression.peek() != ",";
+ };
+
+ while (expression.peek(count) && expression.peek(count) != ",") {
+ count++;
+ }
/*
<position> = [
@@ -5232,40 +5238,48 @@ var ValidationTypes = {
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]
+*/
-*/
-
- if (ValidationTypes.isAny(expression, "top | bottom")) {
- result = true;
+ if (count < 3) {
+ if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
+ result = true;
+ ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, xDir + " | center");
+ }
} else {
-
- //must be two-part
- if (ValidationTypes.isAny(expression, numeric)){
- if (expression.hasNext()){
- result = ValidationTypes.isAny(expression, numeric + " | " + yDir);
- }
- } else if (ValidationTypes.isAny(expression, xDir)){
- if (expression.hasNext()){
-
- //two- or three-part
- if (ValidationTypes.isAny(expression, yDir)){
+ if (ValidationTypes.isAny(expression, xDir)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
result = true;
-
ValidationTypes.isAny(expression, numeric);
-
- } else if (ValidationTypes.isAny(expression, numeric)){
-
- //could also be two-part, so check the next part
- if (ValidationTypes.isAny(expression, yDir)){
- ValidationTypes.isAny(expression, numeric);
- }
-
+ } else if (ValidationTypes.isAny(expression, "center")) {
result = true;
}
}
- }
- }
-
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ result = true;
+ }
+ }
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ }
+ }
+ }
return result;
},
@@ -5372,9 +5386,10 @@ var ValidationTypes = {
};
+
parserlib.css = {
-Colors :Colors,
-Combinator :Combinator,
+Colors :Colors,
+Combinator :Combinator,
Parser :Parser,
PropertyName :PropertyName,
PropertyValue :PropertyValue,
View
32 release/parserlib-tests.js
@@ -1548,6 +1548,22 @@
var result = parser.parse(".foo {\n; color: #fff;\n}");
}
}));
+
+ suite.add(new YUITest.TestCase({
+
+ name: "Invalid CSS Parsing Tests",
+
+ "Test parsing invalid celector": function(){
+ var error;
+ var parser = new Parser();
+ parser.addListener("error", function(e){error = e});
+ parser.parse("c++{}");
+
+ Assert.areEqual("error", error.type);
+ Assert.areEqual(1, error.line);
+ Assert.areEqual(3, error.col);
+ }
+ }));
YUITest.TestRunner.add(suite);
@@ -2411,23 +2427,28 @@
"top",
"bottom",
"center",
+ "100%",
"left center",
+ "bottom left",
"left 10px",
"center bottom",
"10% top",
"left 10px bottom",
"right top 5%",
- "center 3em center 10%",
+ "top 3em center",
+ "center top 3em",
+ "top 3em right 10%",
"top, bottom",
"left 10px, left 10px",
"right top 5%, left 10px bottom"
],
invalid: {
- "foo" : "Expected (<bg-position>) but found 'foo'.",
- "left center right" : "Expected end of value but found 'right'."
-
- }
+ "foo" : "Expected (<bg-position>) but found 'foo'.",
+ "10% left" : "Expected end of value but found 'left'.",
+ "left center right" : "Expected end of value but found 'center'.",
+ "center 3em right 10%": "Expected end of value but found '3em'.",
+ }
}));
suite.add(new ValidationTestCase({
@@ -2569,6 +2590,7 @@
"5px",
"25%",
"5px 25%",
+ "5px / 25%",
"5px 25% / 7px 27%",
"1px 2px 3px 4px / 5px 6px 7px 8px"
],
View
93 release/parserlib.js
@@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v0.1.9, Build time: 23-July-2012 10:52:31 */
+/* Version v0.2.0, Build time: 13-November-2012 01:17:54 */
var parserlib = {};
(function(){
@@ -908,7 +908,7 @@ TokenStreamBase : TokenStreamBase
})();
-/*
+/*
Parser-Lib
Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-/* Version v0.1.9, Build time: 23-July-2012 10:52:31 */
+/* Version v0.2.0, Build time: 13-November-2012 01:17:54 */
(function(){
var EventTarget = parserlib.util.EventTarget,
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2145,7 +2145,7 @@ Parser.prototype = function(){
//there must be a next selector
if (nextSelector === null){
- this._unexpectedToken(this.LT(1));
+ this._unexpectedToken(tokenStream.LT(1));
} else {
//nextSelector is an instance of SelectorPart
@@ -3597,7 +3597,7 @@ var Properties = {
valid = ValidationTypes.isAny(expression, numeric);
if (!valid) {
- if (expression.peek() == "/" && count > 1 && !slash) {
+ if (expression.peek() == "/" && count > 0 && !slash) {
slash = true;
max = count + 5;
expression.next();
@@ -5980,7 +5980,7 @@ var ValidationTypes = {
},
/**
- * Determines if the next part(s) of the given expresion
+ * Determines if the next part(s) of the given expression
* are one of a group.
*/
isAnyOfGroup: function(expression, types) {
@@ -6127,10 +6127,16 @@ var ValidationTypes = {
var types = this,
result = false,
numeric = "<percentage> | <length>",
- xDir = "left | center | right",
- yDir = "top | center | bottom",
- part,
- i, len;
+ xDir = "left | right",
+ yDir = "top | bottom",
+ count = 0,
+ hasNext = function() {
+ return expression.hasNext() && expression.peek() != ",";
+ };
+
+ while (expression.peek(count) && expression.peek(count) != ",") {
+ count++;
+ }
/*
<position> = [
@@ -6142,40 +6148,48 @@ var ValidationTypes = {
[ center | [ left | right ] [ <percentage> | <length> ]? ] &&
[ center | [ top | bottom ] [ <percentage> | <length> ]? ]
]
+*/
-*/
-
- if (ValidationTypes.isAny(expression, "top | bottom")) {
- result = true;
+ if (count < 3) {
+ if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
+ result = true;
+ ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, xDir + " | center");
+ }
} else {
-
- //must be two-part
- if (ValidationTypes.isAny(expression, numeric)){
- if (expression.hasNext()){
- result = ValidationTypes.isAny(expression, numeric + " | " + yDir);
- }
- } else if (ValidationTypes.isAny(expression, xDir)){
- if (expression.hasNext()){
-
- //two- or three-part
- if (ValidationTypes.isAny(expression, yDir)){
+ if (ValidationTypes.isAny(expression, xDir)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, yDir)) {
result = true;
-
ValidationTypes.isAny(expression, numeric);
-
- } else if (ValidationTypes.isAny(expression, numeric)){
-
- //could also be two-part, so check the next part
- if (ValidationTypes.isAny(expression, yDir)){
- ValidationTypes.isAny(expression, numeric);
- }
-
+ } else if (ValidationTypes.isAny(expression, "center")) {
result = true;
}
}
- }
- }
-
+ } else if (ValidationTypes.isAny(expression, yDir)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, numeric)) {
+ if (ValidationTypes.isAny(expression, xDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ result = true;
+ }
+ }
+ } else if (ValidationTypes.isAny(expression, "center")) {
+ if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
+ result = true;
+ ValidationTypes.isAny(expression, numeric);
+ }
+ }
+ }
return result;
},
@@ -6282,9 +6296,10 @@ var ValidationTypes = {
};
+
parserlib.css = {
-Colors :Colors,
-Combinator :Combinator,
+Colors :Colors,
+Combinator :Combinator,
Parser :Parser,
PropertyName :PropertyName,
PropertyValue :PropertyValue,
Please sign in to comment.
Something went wrong with that request. Please try again.