diff --git a/src/SafeAnchor.js b/src/SafeAnchor.js index 8316bbe634..ae45a9c261 100644 --- a/src/SafeAnchor.js +++ b/src/SafeAnchor.js @@ -1,4 +1,5 @@ import React from 'react'; +import createChainedFunction from './utils/createChainedFunction'; /** * Note: This is intended as a stop-gap for accessibility concerns that the @@ -16,17 +17,13 @@ export default class SafeAnchor extends React.Component { if (this.props.href === undefined) { event.preventDefault(); } - - if (this.props.onClick) { - this.props.onClick(event); - } } render() { return ( ); } diff --git a/test/SafeAnchorSpec.js b/test/SafeAnchorSpec.js index 75b9d0a8de..2271c2fbbe 100644 --- a/test/SafeAnchorSpec.js +++ b/test/SafeAnchorSpec.js @@ -43,8 +43,12 @@ describe('SafeAnchor', function() { it('prevents default when no href is provided', function(done) { const handleClick = (event) => { - event.defaultPrevented.should.be.true; - done(); + expect(event.isDefaultPrevented()).to.not.be.ok; + + setTimeout(() => { + event.isDefaultPrevented().should.be.true; + done(); + }, 100); }; const instance = ReactTestUtils.renderIntoDocument(); const anchor = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'A'); @@ -54,8 +58,12 @@ describe('SafeAnchor', function() { it('does not prevent default when href is provided', function(done) { const handleClick = (event) => { - expect(event.defaultPrevented).to.not.be.ok; - done(); + expect(event.isDefaultPrevented()).to.not.be.ok; + + setTimeout(() => { + expect(event.isDefaultPrevented()).to.not.be.ok; + done(); + }); }; const instance = ReactTestUtils.renderIntoDocument(); const anchor = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'A');