Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed issue with attrMap. Since one copy of the map was shared by bei…

…ng part of the Donatello prototype, when we modify the mapping, as in the case of line, which maps stroke-width to CSS border-top-width, subsequent shapes use the same mapping, which is now incorrect. To reproduce this, draw a line followed by a circle. the top stroke of the circle is correct but the rest of the edges will be defaulted to black.
  • Loading branch information...
commit bd66f984f02b8bde5d33a2755e3c9997afa937bc 1 parent 8f5c926
@dnewcome authored
Showing with 21 additions and 17 deletions.
  1. +21 −17 donatello.js
View
38 donatello.js
@@ -20,6 +20,27 @@ function Donatello( id, x, y, w, h ) {
// properties that require a redraw
this.properties = {};
+ /**
+ * Translation between drawing terminology and CSS property
+ * names.
+ *
+ * attr map must be created new for each instance.
+ * later we can optimize, one per shape type, but
+ * this was the source of a bug where one map was shared
+ * between all donatello shapes, which aren't compatible.
+ */
+ this.attrMap = {
+ fill: 'backgroundColor',
+ stroke: 'borderColor',
+ 'stroke-style': 'borderStyle',
+ 'r': 'borderRadius',
+ // type and children are not applied as styles
+ // so we ignore them by setting to null
+ 'type': null,
+ 'children': null,
+ 'transform': Donatello.getTransform()
+ }
+
if( typeof id == 'string' ) {
var el = document.getElementById( id );
Donatello.createElement( x, y, w, h, el );
@@ -79,23 +100,6 @@ Donatello.merge = function( src, dst ) {
return dst;
};
-/**
-* Translation between drawing terminology and CSS property
-* names.
-*/
-Donatello.prototype.attrMap = {
- fill: 'backgroundColor',
- stroke: 'borderColor',
- 'stroke-style': 'borderStyle',
- 'r': 'borderRadius',
- // type and children are not applied as styles
- // so we ignore them by setting to null
- 'type': null,
- 'children': null,
- 'transform': Donatello.getTransform()
-}
-
-
/**
* Each type of donatello shape needs to impelement draw
*/
Please sign in to comment.
Something went wrong with that request. Please try again.