Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngShow does not show the svg element correctly when using jquery 2.1.1 and ngAnimate at the same time #8872

Closed
merlinchen opened this issue Sep 1, 2014 · 4 comments

Comments

@merlinchen
Copy link

There is a regression between beta.19 and rc.0.

beta.19:http://plnkr.co/edit/zkPRL7Cu0YCFs0y25oSf?p=preview
rc.0:http://plnkr.co/edit/uL9yduQne0HMarug27Zk?p=preview

When click the toggle button, the rect element did not show as expected.
This only happens when jquery 2.1.1 is included and ngAnimate is required in module definition.

@merlinchen merlinchen changed the title ngShow did not show the svg element correctly when using jquery 2.1.1 and ngAnimate at the same time ngShow does not show the svg element correctly when using jquery 2.1.1 and ngAnimate at the same time Sep 1, 2014
merlinchen referenced this issue Sep 2, 2014
…igest loop

All class-based animation methods (addClass, removeClass and setClass) on $animate
are now processed after the next digest occurs. This fix prevents any sequencing
errors from occuring from excessive calls to $animate.addClass, $animate.remoteClass
or $animate.setClass.

BREAKING CHANGE

$animate.addClass, $animate.removeClass and $animate.setClass will no longer start the animation
right after being called in the directive code. The animation will only commence once a digest
has passed. This means that all animation-related testing code requires an extra digest to kick
off the animation.

```js
//before this fix
$animate.addClass(element, 'super');
expect(element).toHaveClass('super');

//now
$animate.addClass(element, 'super');
$rootScope.$digest();
expect(element).toHaveClass('super');
```

$animate will also tally the amount of times classes are added and removed and only animate
the left over classes once the digest kicks in. This means that for any directive code that
adds and removes the same CSS class on the same element then this may result in no animation
being triggered at all.

```js
$animate.addClass(element, 'klass');
$animate.removeClass(element, 'klass');

$rootScope.$digest();

//nothing happens...
```
@merlinchen
Copy link
Author

@caitp This regression is introduced by 2f4437b. jquery's hasClass method returns false on svg element which cause ng-hide class not be removed.

@caitp
Copy link
Contributor

caitp commented Sep 2, 2014

@merlinchen you can just use https://github.com/kbwood/svg/blob/master/jquery.svgdom.js to monkeypatch jQuery and make it work correctly.

@merlinchen
Copy link
Author

@caitp Got it. Thanks.

@caitp
Copy link
Contributor

caitp commented Sep 2, 2014

So this should be fixable with jQuery.svgdom, but it is awkward that this worked before and not now --- I'm going to consider this a regression unless anyone says we have a good reason to use jQuery's hasClass.

@caitp caitp added this to the 1.3.0-rc.1 milestone Sep 2, 2014
@caitp caitp self-assigned this Sep 2, 2014
caitp added a commit to caitp/angular.js that referenced this issue Sep 2, 2014
… jQuery

Without this CL, ngShowHide will not work without the use of monkeypatched fixes for jQuery such as
https://github.com/kbwood/svg 's jquery-svgdom.js script.

Closes angular#8872
caitp added a commit to caitp/angular.js that referenced this issue Sep 4, 2014
… jQuery

Without this CL, ngShowHide will not work without the use of monkeypatched fixes for jQuery such as
https://github.com/kbwood/svg 's jquery-svgdom.js script.

Closes angular#8872
@caitp caitp closed this as completed in b3b6721 Sep 5, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants