Browse Source

handle leading and trailing spaces

tags/2.3.6
dotnetCarpenter 7 years ago
parent
commit
695f26a8df
No account linked to committer's email address
4 changed files with 9 additions and 4 deletions
  1. 2
    2
      dist/svg.js
  2. 1
    1
      dist/svg.min.js
  3. 5
    0
      spec/spec/array.js
  4. 1
    1
      src/pointarray.js

+ 2
- 2
dist/svg.js View File

@@ -6,7 +6,7 @@
* @copyright Wout Fierens <wout@woutfierens.com>
* @license MIT
*
* BUILT: Thu Oct 20 2016 15:35:29 GMT-0200 (WGST)
* BUILT: Thu Oct 20 2016 16:47:32 GMT-0200 (WGST)
*/;
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
@@ -556,7 +556,7 @@ SVG.extend(SVG.PointArray, {
if (Array.isArray(array)) return array

// parse points
array = array.split(/\s+|,/)
array = array.trim().split(/\s+|,/)

// validate points - https://svgwg.org/svg2-draft/shapes.html#DataTypePoints
// Odd number of coordinates is an error. In such cases, drop the last odd coordinate.

+ 1
- 1
dist/svg.min.js
File diff suppressed because it is too large
View File


+ 5
- 0
spec/spec/array.js View File

@@ -43,6 +43,11 @@ describe('PointArray', function () {

expect(array + '').toBe('2176.6,1708.8 2176.4,1755.8 2245.8,1801.5 2297,1787.8')
})
it('parses points with space delimitered x/y coordinates', function() {
var array = new SVG.PointArray(' 1 2 3 ')

expect(array + '').toBe('1,2,3')
})
})

describe('PathArray', function () {

+ 1
- 1
src/pointarray.js View File

@@ -48,7 +48,7 @@ SVG.extend(SVG.PointArray, {
if (Array.isArray(array)) return array

// parse points
array = array.split(/\s+|,/)
array = array.trim().split(/\s+|,/)

// validate points - https://svgwg.org/svg2-draft/shapes.html#DataTypePoints
// Odd number of coordinates is an error. In such cases, drop the last odd coordinate.

Loading…
Cancel
Save