Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
92b6e8011e | |||
|
a3494b3421 | ||
|
330ffa92cd | ||
cce801d1df | |||
eff630c873 | |||
c4ba2836b6 | |||
015088b929 | |||
|
4bfe95a98f |
8 changed files with 11014 additions and 8 deletions
|
@ -142,6 +142,7 @@ GradientParser.stringify = (function() {
|
||||||
if (!element) {
|
if (!element) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
var result = '';
|
||||||
|
|
||||||
if (element instanceof Array) {
|
if (element instanceof Array) {
|
||||||
return visitor.visit_array(element, result);
|
return visitor.visit_array(element, result);
|
||||||
|
@ -264,7 +265,7 @@ GradientParser.parse = (function() {
|
||||||
error('Missing (');
|
error('Missing (');
|
||||||
}
|
}
|
||||||
|
|
||||||
result = callback(captures);
|
var result = callback(captures);
|
||||||
|
|
||||||
if (!scan(tokens.endCall)) {
|
if (!scan(tokens.endCall)) {
|
||||||
error('Missing )');
|
error('Missing )');
|
||||||
|
|
|
@ -100,7 +100,7 @@ GradientParser.parse = (function() {
|
||||||
error('Missing (');
|
error('Missing (');
|
||||||
}
|
}
|
||||||
|
|
||||||
result = callback(captures);
|
var result = callback(captures);
|
||||||
|
|
||||||
if (!scan(tokens.endCall)) {
|
if (!scan(tokens.endCall)) {
|
||||||
error('Missing )');
|
error('Missing )');
|
||||||
|
@ -491,6 +491,7 @@ GradientParser.stringify = (function() {
|
||||||
if (!element) {
|
if (!element) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
var result = '';
|
||||||
|
|
||||||
if (element instanceof Array) {
|
if (element instanceof Array) {
|
||||||
return visitor.visit_array(element, result);
|
return visitor.visit_array(element, result);
|
||||||
|
|
|
@ -11,7 +11,7 @@ GradientParser.parse = (function() {
|
||||||
repeatingLinearGradient: /^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,
|
repeatingLinearGradient: /^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,
|
||||||
radialGradient: /^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,
|
radialGradient: /^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,
|
||||||
repeatingRadialGradient: /^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,
|
repeatingRadialGradient: /^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,
|
||||||
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|left|right|top|bottom)/i,
|
sideOrCorner: /^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,
|
||||||
extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
|
extentKeywords: /^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,
|
||||||
positionKeywords: /^(left|center|right|top|bottom)/i,
|
positionKeywords: /^(left|center|right|top|bottom)/i,
|
||||||
pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
|
pixelValue: /^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,
|
||||||
|
|
|
@ -142,6 +142,7 @@ GradientParser.stringify = (function() {
|
||||||
if (!element) {
|
if (!element) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
var result = '';
|
||||||
|
|
||||||
if (element instanceof Array) {
|
if (element instanceof Array) {
|
||||||
return visitor.visit_array(element, result);
|
return visitor.visit_array(element, result);
|
||||||
|
|
10999
package-lock.json
generated
Normal file
10999
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "gradient-parser",
|
"name": "gradient-parser",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"description": "Parse CSS3 gradient definitions and return an AST.",
|
"description": "Parse CSS3 gradient definitions and return an AST.",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Rafael Carcicio",
|
"name": "Rafael Carcicio",
|
||||||
|
@ -32,8 +32,8 @@
|
||||||
"css3",
|
"css3",
|
||||||
"parser"
|
"parser"
|
||||||
],
|
],
|
||||||
"dependencies": {},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"expect.js": "*",
|
||||||
"grunt": "*",
|
"grunt": "*",
|
||||||
"grunt-browserify": "^3.0.1",
|
"grunt-browserify": "^3.0.1",
|
||||||
"grunt-complexity": "*",
|
"grunt-complexity": "*",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var expect = require('expect.js');
|
var expect = require('expect.js');
|
||||||
var gradients = require('build/node');
|
var gradients = require('../build/node');
|
||||||
|
|
||||||
|
|
||||||
describe('lib/parser.js', function () {
|
describe('lib/parser.js', function () {
|
||||||
|
@ -134,7 +134,11 @@ describe('lib/parser.js', function () {
|
||||||
describe('parse all linear directional', function() {
|
describe('parse all linear directional', function() {
|
||||||
[
|
[
|
||||||
{type: 'angular', unparsedValue: '-145deg', value: '-145'},
|
{type: 'angular', unparsedValue: '-145deg', value: '-145'},
|
||||||
{type: 'directional', unparsedValue: 'to left top', value: 'left top'}
|
{type: 'directional', unparsedValue: 'to left top', value: 'left top'},
|
||||||
|
{type: 'directional', unparsedValue: 'to top left', value: 'top left'},
|
||||||
|
{type: 'directional', unparsedValue: 'to top right', value: 'top right'},
|
||||||
|
{type: 'directional', unparsedValue: 'to bottom left', value: 'bottom left'},
|
||||||
|
{type: 'directional', unparsedValue: 'to bottom right', value: 'bottom right'}
|
||||||
].forEach(function(orientation) {
|
].forEach(function(orientation) {
|
||||||
describe('parse orientation ' + orientation.type, function() {
|
describe('parse orientation ' + orientation.type, function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var expect = require('expect.js');
|
var expect = require('expect.js');
|
||||||
var gradients = require('build/node');
|
var gradients = require('../build/node');
|
||||||
|
|
||||||
function pprint(ast) {
|
function pprint(ast) {
|
||||||
console.log(JSON.stringify(ast, true, 2));
|
console.log(JSON.stringify(ast, true, 2));
|
||||||
|
|
Loading…
Reference in a new issue