Skip to content

Commit 1e29e0c

Browse files
committed
A little cleanup for validation with hacks
1 parent 34a5675 commit 1e29e0c

File tree

7 files changed

+69
-24
lines changed

7 files changed

+69
-24
lines changed

build/node-parserlib.js

Lines changed: 13 additions & 5 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: 26-April-2012 09:31:25 */
24+
/* Version v@VERSION@, Build time: 4-May-2012 03:29:22 */
2525
var parserlib = {};
2626
(function(){
2727

@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
931931
THE SOFTWARE.
932932
933933
*/
934-
/* Version v@VERSION@, Build time: 26-April-2012 09:31:25 */
934+
/* Version v@VERSION@, Build time: 4-May-2012 03:29:22 */
935935
(function(){
936936
var EventTarget = parserlib.util.EventTarget,
937937
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2640,7 +2640,8 @@ Parser.prototype = function(){
26402640
expr = null,
26412641
prio = null,
26422642
error = null,
2643-
invalid = null;
2643+
invalid = null,
2644+
propertyName= "";
26442645

26452646
property = this._property();
26462647
if (property !== null){
@@ -2657,8 +2658,15 @@ Parser.prototype = function(){
26572658

26582659
prio = this._prio();
26592660

2661+
propertyName = property.toString();
2662+
if (this.options.starHack && property.hack == "*" ||
2663+
this.options.underscoreHack && property.hack == "_") {
2664+
2665+
propertyName = property.text;
2666+
}
2667+
26602668
try {
2661-
this._validateProperty(property.text, expr);
2669+
this._validateProperty(propertyName, expr);
26622670
} catch (ex) {
26632671
invalid = ex;
26642672
}
@@ -6017,7 +6025,7 @@ var ValidationTypes = {
60176025
},
60186026

60196027
"<gradient>": function(part) {
6020-
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial|linear)\-gradient/i.test(part);
6028+
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
60216029
},
60226030

60236031
"<box>": function(part){

build/npm/lib/node-parserlib.js

Lines changed: 13 additions & 5 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: 26-April-2012 09:31:25 */
24+
/* Version v@VERSION@, Build time: 4-May-2012 03:29:22 */
2525
var parserlib = {};
2626
(function(){
2727

@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
931931
THE SOFTWARE.
932932
933933
*/
934-
/* Version v@VERSION@, Build time: 26-April-2012 09:31:25 */
934+
/* Version v@VERSION@, Build time: 4-May-2012 03:29:22 */
935935
(function(){
936936
var EventTarget = parserlib.util.EventTarget,
937937
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2640,7 +2640,8 @@ Parser.prototype = function(){
26402640
expr = null,
26412641
prio = null,
26422642
error = null,
2643-
invalid = null;
2643+
invalid = null,
2644+
propertyName= "";
26442645

26452646
property = this._property();
26462647
if (property !== null){
@@ -2657,8 +2658,15 @@ Parser.prototype = function(){
26572658

26582659
prio = this._prio();
26592660

2661+
propertyName = property.toString();
2662+
if (this.options.starHack && property.hack == "*" ||
2663+
this.options.underscoreHack && property.hack == "_") {
2664+
2665+
propertyName = property.text;
2666+
}
2667+
26602668
try {
2661-
this._validateProperty(property.text, expr);
2669+
this._validateProperty(propertyName, expr);
26622670
} catch (ex) {
26632671
invalid = ex;
26642672
}
@@ -6017,7 +6025,7 @@ var ValidationTypes = {
60176025
},
60186026

60196027
"<gradient>": function(part) {
6020-
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial|linear)\-gradient/i.test(part);
6028+
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
60216029
},
60226030

60236031
"<box>": function(part){

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: 26-April-2012 09:31:25 */
24+
/* Version v@VERSION@, Build time: 4-May-2012 03:29:22 */
2525
var parserlib = {};
2626
(function(){
2727

build/parserlib-css.js

Lines changed: 12 additions & 4 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: 26-April-2012 09:31:25 */
24+
/* Version v@VERSION@, Build time: 4-May-2012 03:29:22 */
2525
(function(){
2626
var EventTarget = parserlib.util.EventTarget,
2727
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -1730,7 +1730,8 @@ Parser.prototype = function(){
17301730
expr = null,
17311731
prio = null,
17321732
error = null,
1733-
invalid = null;
1733+
invalid = null,
1734+
propertyName= "";
17341735

17351736
property = this._property();
17361737
if (property !== null){
@@ -1747,8 +1748,15 @@ Parser.prototype = function(){
17471748

17481749
prio = this._prio();
17491750

1751+
propertyName = property.toString();
1752+
if (this.options.starHack && property.hack == "*" ||
1753+
this.options.underscoreHack && property.hack == "_") {
1754+
1755+
propertyName = property.text;
1756+
}
1757+
17501758
try {
1751-
this._validateProperty(property.text, expr);
1759+
this._validateProperty(propertyName, expr);
17521760
} catch (ex) {
17531761
invalid = ex;
17541762
}
@@ -5107,7 +5115,7 @@ var ValidationTypes = {
51075115
},
51085116

51095117
"<gradient>": function(part) {
5110-
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial|linear)\-gradient/i.test(part);
5118+
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
51115119
},
51125120

51135121
"<box>": function(part){

build/parserlib-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2384,8 +2384,8 @@
23842384
"radial-gradient(top, #f2f2f2 0%, #cbcbcb 100%)",
23852385
"repeating-linear-gradient(top, #f2f2f2 0%, #cbcbcb 100%)",
23862386
"repeating-radial-gradient(top, #f2f2f2 0%, #cbcbcb 100%)",
2387-
"-ms-linear-gradient(top, #f2f2f2 0%, #cbcbcb 100%), url(foo.png)"
2388-
2387+
"-ms-linear-gradient(top, #f2f2f2 0%, #cbcbcb 100%), url(foo.png)",
2388+
"-webkit-gradient(linear, left bottom, left top, from(#f2f2f2), to(#cbcbcb))"
23892389
],
23902390

23912391
invalid: {

build/parserlib.js

Lines changed: 13 additions & 5 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: 26-April-2012 09:31:25 */
24+
/* Version v@VERSION@, Build time: 4-May-2012 03:29:22 */
2525
var parserlib = {};
2626
(function(){
2727

@@ -931,7 +931,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
931931
THE SOFTWARE.
932932
933933
*/
934-
/* Version v@VERSION@, Build time: 26-April-2012 09:31:25 */
934+
/* Version v@VERSION@, Build time: 4-May-2012 03:29:22 */
935935
(function(){
936936
var EventTarget = parserlib.util.EventTarget,
937937
TokenStreamBase = parserlib.util.TokenStreamBase,
@@ -2640,7 +2640,8 @@ Parser.prototype = function(){
26402640
expr = null,
26412641
prio = null,
26422642
error = null,
2643-
invalid = null;
2643+
invalid = null,
2644+
propertyName= "";
26442645

26452646
property = this._property();
26462647
if (property !== null){
@@ -2657,8 +2658,15 @@ Parser.prototype = function(){
26572658

26582659
prio = this._prio();
26592660

2661+
propertyName = property.toString();
2662+
if (this.options.starHack && property.hack == "*" ||
2663+
this.options.underscoreHack && property.hack == "_") {
2664+
2665+
propertyName = property.text;
2666+
}
2667+
26602668
try {
2661-
this._validateProperty(property.text, expr);
2669+
this._validateProperty(propertyName, expr);
26622670
} catch (ex) {
26632671
invalid = ex;
26642672
}
@@ -6017,7 +6025,7 @@ var ValidationTypes = {
60176025
},
60186026

60196027
"<gradient>": function(part) {
6020-
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial|linear)\-gradient/i.test(part);
6028+
return part.type == "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
60216029
},
60226030

60236031
"<box>": function(part){

src/css/Parser.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,8 @@ Parser.prototype = function(){
14401440
expr = null,
14411441
prio = null,
14421442
error = null,
1443-
invalid = null;
1443+
invalid = null,
1444+
propertyName= "";
14441445

14451446
property = this._property();
14461447
if (property !== null){
@@ -1457,8 +1458,20 @@ Parser.prototype = function(){
14571458

14581459
prio = this._prio();
14591460

1461+
/*
1462+
* If hacks should be allowed, then only check the root
1463+
* property. If hacks should not be allowed, treat
1464+
* _property or *property as invalid properties.
1465+
*/
1466+
propertyName = property.toString();
1467+
if (this.options.starHack && property.hack == "*" ||
1468+
this.options.underscoreHack && property.hack == "_") {
1469+
1470+
propertyName = property.text;
1471+
}
1472+
14601473
try {
1461-
this._validateProperty(property.text, expr);
1474+
this._validateProperty(propertyName, expr);
14621475
} catch (ex) {
14631476
invalid = ex;
14641477
}

0 commit comments

Comments
 (0)