DmitryBaranovskiy/raphael — Issue #534: Setting fill attribute using attr() fails to recognize existing SVG pattern object
Author: md3sum
Created: 2012-03-09 00:05:32+00:00
State: open

If I were to define a pattern in SVG, earlier in the file and then try to refer to the defined pattern by ID in the fill attribute, it fails.

```javascript
var abox = paper.rect(0,0,20,20).attr(fill:"url(#test-pattern)");
```

If you were to edit the file directly and enforce that the `fill` parameter's value is `url(#test-pattern)`, then it works.
The issue seems to arise in `setFillAndStroke()` over [here](https://github.com/DmitryBaranovskiy/raphael/blob/master/raphael.svg.js#L466) where it evaluates the 'fill' attribute.

It seems to be generating a new ID and creating a new pattern object and image element. Maybe it could just check to see if the element with that ID exists in the document first and just set it to that directly. If not, then it can continue processing what it currently does?

Thoughts anyone?