Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
test(md-button): adds test for previous ripple issue
Browse files Browse the repository at this point in the history
Closes #1121.
  • Loading branch information
robertmesserle committed Jan 6, 2015
1 parent 5e489e9 commit d6bd69a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/components/button/button.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,11 @@ describe('md-button', function() {
expect(button[0].hasAttribute('hide-sm')).toBe(true);
}));

it('should only have one ripple container when a custom ripple color is set', inject(function ($compile, $rootScope, $timeout) {
var button = $compile('<md-button md-ink-ripple="#f00">button</md-button>')($rootScope);
var scope = button.eq(0).scope();
scope._onInput({ isFirst: true, eventType: Hammer.INPUT_START, center: { x: 0, y: 0 } });
expect(button[0].getElementsByClassName('md-ripple-container').length).toBe(1);
}));

});
7 changes: 5 additions & 2 deletions src/core/services/ripple/ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ function InkRippleService($window, $timeout) {
hammertime = new Hammer(node),
color = parseColor(element.attr('md-ink-ripple')) || parseColor($window.getComputedStyle(options.colorElement[0]).color || 'rgb(0, 0, 0)');

// expose onInput for ripple testing
scope._onInput = onInput;

options.mousedown && hammertime.on('hammer.input', onInput);

controller.createRipple = createRipple;
Expand Down Expand Up @@ -313,7 +316,7 @@ function InkRippleService($window, $timeout) {
*/
function getRippleContainer() {
if (rippleContainer) return rippleContainer;
var container = rippleContainer = angular.element('<div class="md-ripple-container">');
var container = rippleContainer = angular.element('<div class="md-ripple-container"></div>');
element.append(container);
return container;
}
Expand Down Expand Up @@ -346,7 +349,7 @@ function InkRippleService($window, $timeout) {
var grandparent = parent && parent.parentNode;
var ancestor = grandparent && grandparent.parentNode;
return !node.hasAttribute('disabled') &&
!(parent && parent.hasAttribute('disabled')) &&
!(parent && parent.hasAttribute && parent.hasAttribute('disabled')) &&
!(grandparent && grandparent.hasAttribute('disabled')) &&
!(ancestor && ancestor.hasAttribute('disabled'));
}
Expand Down

0 comments on commit d6bd69a

Please sign in to comment.