Permalink
Browse files

Fix a bug where the filter-attribute wasn't removed

  • Loading branch information...
1 parent c1c3e23 commit f2a6a32d0946049ccf71da111d0dfba4019c58dc @basecode basecode committed Aug 24, 2012
Showing with 33 additions and 19 deletions.
  1. +1 −0 CHANGELOG
  2. +25 −0 example/library/movies/filter-frames.js
  3. +1 −0 example/library/movies/movie_list.js
  4. +6 −19 src/renderer/svg/svg.js
View
@@ -8,6 +8,7 @@ v0.3.4
as second parameter to `parent.insertBefore` (thx @jdalton)
* Add `diffX` and `diffY` properties to `pointerup` event object.
* Fix #36 where filters couldn't be removed (thx @qfox)
+* Fix a bug where the filter-attribute wasn't removed
v0.3.3
-------------------
@@ -0,0 +1,25 @@
+// one
+var _red = Path.rect(30,30,50,50).attr({
+ fillColor:'red'
+}).addTo(stage);
+
+// two
+var _orange = Path.rect(130,30,50,50).attr({
+ fillColor:'orange'
+}).addTo(stage);
+
+
+stage.frames({
+ '1s': function() {
+ _red.attr('filters', new filter.Blur(2));
+ },
+ '2s' : function() {
+ _orange.attr('filters', new filter.Blur(2));
+ },
+ '3s' : function() {
+ _red.attr('filters', null);
+ },
+ '4s' : function() {
+ _orange.attr('filters', null);
+ }
+});
@@ -68,6 +68,7 @@ movieList = {
'filter-blur.js',
'filter-list.js',
'filter-multi.js',
+ 'filter-frames.js',
'filter-colorMatrix-shim.js',
'filter-colorMatrix-shim-2.js'
],
View
@@ -734,9 +734,7 @@ define([
this.removeGradient(element, 'stroke');
this.removeMask(element);
-
- element._filterSignature &&
- this.removeFilters(element);
+ this.removeFilters(element);
};
proto.removeFilters = function(element) {
@@ -746,6 +744,7 @@ define([
var signature = element._filterSignature,
def = this.definitions[signature];
+ // return early when no filter was previously applied
if (!def) {
return;
}
@@ -757,6 +756,8 @@ define([
delete this.definitions[signature];
}
+ // remove filter-attribute and internal filter-reference
+ element.removeAttribute('filter');
delete element._filterSignature;
};
@@ -1303,22 +1304,8 @@ define([
return;
}
- // If the element already has an attached filter we may be able
- // to use it (as long as it's not being used by something else)
- if (element._filterSignature) {
-
- filterDef = this.definitions[element._filterSignature];
-
- if (filterDef.n > 1) {
- // decrease retain count b/c filter is used by other elements
- filterDef.n--;
- } else {
- // remove old filter
- filterDef.element.parentNode.removeChild(filterDef.element);
- element.removeAttribute('filter');
- delete this.definitions[element._filterSignature];
- }
- }
+ // remove already applied filters
+ this.removeFilters(element);
var filterContainer = createElement('filter');

0 comments on commit f2a6a32

Please sign in to comment.