Skip to content

Commit

Permalink
Merge pull request #30 from Grafikart/fix-chrome-52
Browse files Browse the repository at this point in the history
Fixed a bug with SVG on Chrome 52
  • Loading branch information
mv-stripe authored Aug 12, 2016
2 parents 16440ca + 061f171 commit bde5596
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dynamics.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ getCurrentProperties = (el, keys) ->
properties['transform'] = matrix.decompose()
else
v = style[key]
if !v? && svgProperties.contains(key)
if (!v? or key is 'd') && svgProperties.contains(key)
v = el.getAttribute(key)
if v == "" or !v?
v = defaultValueForKey(key)
Expand Down
24 changes: 24 additions & 0 deletions test/dynamics.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,30 @@ describe 'dynamics.animate', ->
done()
, 150


it 'animates the points of a svg path correctly', (done) ->
el = document.createElement('path')

# On chrome 52 getComputedStyle give a "d" property for path
# Mock window.getComputedStyle
style = window.getComputedStyle(el, null)
style.setProperty('d', 'path(10 20 30)')
oldComputed = window.getComputedStyle
window.getComputedStyle = (el, pseudoElt) -> style

dynamics.tests.isSVG = (el) -> true
el.setAttribute("d", "M101.88,22 C101.88,18.25")
dynamics.animate(el, {
d: "M50,10 C88.11,20.45"
}, {
duration: 100
})
setTimeout ->
expect(el.getAttribute("d")[0]).to.be.equal('M')
window.getComputedStyle = oldComputed # remove mock to avoid conflict for the next test
done()
, 50

it 'animates properties of an object correctly', (done) ->
assertTypes = (object) ->
expect(typeof(object.number)).to.be.equal('number', 'object.number has the wrong type')
Expand Down

0 comments on commit bde5596

Please sign in to comment.