From b0306986f806b9a917966fcf0ae9bf13d5d2e23b Mon Sep 17 00:00:00 2001 From: Alan Cutter Date: Wed, 12 Apr 2017 18:05:54 +1000 Subject: [PATCH 1/3] updateNodeToV6 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 238052ac..bf9039b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js node_js: - - "4.4.4" + - "6.10.2" install: - BROWSER="Firefox-stable" ./.travis-setup.sh From a9b723540536e123408c853cdef94fcc9642db81 Mon Sep 17 00:00:00 2001 From: Alan Cutter Date: Wed, 12 Apr 2017 16:28:57 +1000 Subject: [PATCH 2/3] fixColorTest --- test/js/color-handler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/js/color-handler.js b/test/js/color-handler.js index eb0950b0..2437ea44 100644 --- a/test/js/color-handler.js +++ b/test/js/color-handler.js @@ -11,7 +11,7 @@ suite('color-handler', function() { test('invalid colors fail to parse', function() { assert.isUndefined(parseColor('')); assert.isUndefined(parseColor('bananayellow')); - assert.isUndefined(parseColor('rgb(10, 20, 30, 40)')); + assert.isUndefined(parseColor('rgb(10, 20, 30, 40, 50)')); }); test('color interpolation', function() { assert.equal(webAnimations1.propertyInterpolation('color', '#00aa11', '#aa00bb')(0.2), 'rgba(34,136,51,1)'); From aad64559585b2b4d2b4e30b06621c47096b09874 Mon Sep 17 00:00:00 2001 From: Alan Cutter Date: Wed, 12 Apr 2017 16:10:51 +1000 Subject: [PATCH 3/3] strokeDasharray --- src/number-handler.js | 29 ++++++++++++++++++++++++++++- src/property-interpolation.js | 1 + test/js/box-handler.js | 2 +- test/js/color-handler.js | 4 ++-- test/js/dimension-handler.js | 2 +- test/js/number-handler.js | 7 +++++++ 6 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/number-handler.js b/src/number-handler.js index 95ae4617..2a340ecb 100644 --- a/src/number-handler.js +++ b/src/number-handler.js @@ -16,7 +16,7 @@ (function(scope, testing) { function numberToString(x) { - return x.toFixed(3).replace('.000', ''); + return x.toFixed(3).replace(/0+$/, '').replace(/\.$/, ''); } function clamp(min, max, x) { @@ -53,11 +53,37 @@ }; } + function parseNumberList(string) { + var items = string.trim().split(/\s*[\s,]\s*/); + if (items.length === 0) { + return; + } + var result = []; + for (var i = 0; i < items.length; i++) { + var number = parseNumber(items[i]); + if (number === undefined) { + return; + } + result.push(number); + } + return result; + } + + function mergeNumberLists(left, right) { + if (left.length != right.length) { + return; + } + return [left, right, function(numberList) { + return numberList.map(numberToString).join(' '); + }]; + } + function round(left, right) { return [left, right, Math.round]; } scope.clamp = clamp; + scope.addPropertiesHandler(parseNumberList, mergeNumberLists, ['stroke-dasharray']); scope.addPropertiesHandler(parseNumber, clampedMergeNumbers(0, Infinity), ['border-image-width', 'line-height']); scope.addPropertiesHandler(parseNumber, clampedMergeNumbers(0, 1), ['opacity', 'shape-image-threshold']); scope.addPropertiesHandler(parseNumber, mergeFlex, ['flex-grow', 'flex-shrink']); @@ -65,6 +91,7 @@ scope.addPropertiesHandler(parseNumber, round, ['z-index']); scope.parseNumber = parseNumber; + scope.parseNumberList = parseNumberList; scope.mergeNumbers = mergeNumbers; scope.numberToString = numberToString; diff --git a/src/property-interpolation.js b/src/property-interpolation.js index 3e863bdc..89322571 100644 --- a/src/property-interpolation.js +++ b/src/property-interpolation.js @@ -79,6 +79,7 @@ paddingRight: '0px', paddingTop: '0px', right: 'auto', + strokeDasharray: 'none', strokeDashoffset: '0px', textIndent: '0px', textShadow: '0px 0px 0px transparent', diff --git a/test/js/box-handler.js b/test/js/box-handler.js index 6aff2dbb..6e731e98 100644 --- a/test/js/box-handler.js +++ b/test/js/box-handler.js @@ -46,7 +46,7 @@ suite('box-handler', function() { 'Round interpolation result'); assert.equal( webAnimations1.propertyInterpolation('clip', 'rect(10px, 10px, 10px, 10px)', 'rect(20px, 20px, 20px, 20px)')(0.25), - 'rect(12.500px, 12.500px, 12.500px, 12.500px)', + 'rect(12.5px, 12.5px, 12.5px, 12.5px)', 'Round interpolation result'); assert.equal( webAnimations1.propertyInterpolation('clip', 'rect(10px, 10%, 10px, 10%)', 'rect(10em, 10px, 10em, 10px)')(0.4), diff --git a/test/js/color-handler.js b/test/js/color-handler.js index 2437ea44..9ffe0564 100644 --- a/test/js/color-handler.js +++ b/test/js/color-handler.js @@ -16,7 +16,7 @@ suite('color-handler', function() { test('color interpolation', function() { assert.equal(webAnimations1.propertyInterpolation('color', '#00aa11', '#aa00bb')(0.2), 'rgba(34,136,51,1)'); assert.equal(webAnimations1.propertyInterpolation('color', 'transparent', '#004488')(0), 'transparent'); - assert.equal(webAnimations1.propertyInterpolation('color', 'transparent', '#004488')(0.5), 'rgba(0,68,136,0.500)'); + assert.equal(webAnimations1.propertyInterpolation('color', 'transparent', '#004488')(0.5), 'rgba(0,68,136,0.5)'); assert.equal(webAnimations1.propertyInterpolation('color', 'red', 'green')(2), 'rgba(0,255,0,1)'); assert.equal(webAnimations1.propertyInterpolation('color', 'red', 'green')(-1), 'rgba(255,0,0,1)'); }); @@ -28,6 +28,6 @@ suite('color-handler', function() { assert.equal(webAnimations1.propertyInterpolation('stroke', '#00fe00', '#180036')(0.5), 'rgba(12,127,27,1)'); }); test('interpolation to/from initial', function() { - assert.equal(webAnimations1.propertyInterpolation('backgroundColor', 'initial', 'red')(0.5), 'rgba(255,0,0,0.500)'); + assert.equal(webAnimations1.propertyInterpolation('backgroundColor', 'initial', 'red')(0.5), 'rgba(255,0,0,0.5)'); }); }); diff --git a/test/js/dimension-handler.js b/test/js/dimension-handler.js index 00ebeebe..baa04253 100644 --- a/test/js/dimension-handler.js +++ b/test/js/dimension-handler.js @@ -43,7 +43,7 @@ suite('dimension-handler', function() { assert.equal(webAnimations1.propertyInterpolation('left', '10px', '50px')(0.25), '20px'); assert.equal(webAnimations1.propertyInterpolation('left', '10%', '50%')(0.25), '20%'); assert.equal(webAnimations1.propertyInterpolation('left', '0px', '0.001px')(0.05), '0px'); - assert.equal(webAnimations1.propertyInterpolation('left', '0px', '10px')(0.234), '2.340px'); + assert.equal(webAnimations1.propertyInterpolation('left', '0px', '10px')(0.234), '2.34px'); assert.equal(webAnimations1.propertyInterpolation('left', '10px', '10em')(0.4), 'calc(6px + 4em)'); assert.equal(webAnimations1.propertyInterpolation('left', '10px', '10%')(0.4), 'calc(6px + 4%)'); assert.equal(webAnimations1.propertyInterpolation('left', 'calc(10px + 5em)', 'calc(20px + 35em)')(0.4), 'calc(14px + 17em)'); diff --git a/test/js/number-handler.js b/test/js/number-handler.js index 0b42c30d..b4639e40 100644 --- a/test/js/number-handler.js +++ b/test/js/number-handler.js @@ -19,6 +19,12 @@ suite('number-handler', function() { assert.equal(webAnimations1.parseNumber(string), tests[string], 'Parsing "' + string + '"'); } }); + test('number list interpolation', function() { + assert.equal(webAnimations1.propertyInterpolation('strokeDasharray', '10', '20')(0.25), '12.5'); + assert.equal(webAnimations1.propertyInterpolation('strokeDasharray', '10 100', '20 200')(0.25), '12.5 125'); + assert.equal(webAnimations1.propertyInterpolation('strokeDasharray', '10, 100', '20, 200')(0.25), '12.5 125'); + assert.equal(webAnimations1.propertyInterpolation('strokeDasharray', '10,100', '20 200')(0.25), '12.5 125'); + }); test('invalid numbers fail to parse', function() { assert.isUndefined(webAnimations1.parseNumber('')); assert.isUndefined(webAnimations1.parseNumber('nine')); @@ -26,6 +32,7 @@ suite('number-handler', function() { assert.isUndefined(webAnimations1.parseNumber('+-0')); assert.isUndefined(webAnimations1.parseNumber('50px')); assert.isUndefined(webAnimations1.parseNumber('1.2.3')); + assert.isUndefined(webAnimations1.parseNumberList('10,,20')); }); test('opacity clamping', function() { var interpolation = webAnimations1.propertyInterpolation('opacity', '0', '1');