Skip to content

Commit

Permalink
Merge pull request facebook#4744 from spicyj/facebookgh-4635-f
Browse files Browse the repository at this point in the history
Fix code style/grammar on synthetic event warning
  • Loading branch information
sophiebits committed Aug 31, 2015
2 parents dc23faf + 42602a8 commit 0e2bf2f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
30 changes: 18 additions & 12 deletions src/renderers/dom/client/syntheticEvents/SyntheticEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,17 @@ assign(SyntheticEvent.prototype, {
this.defaultPrevented = true;
var event = this.nativeEvent;
if (__DEV__) {
warning(event,
'This Synthetic event is reused for performance reasons. If you\'re seeing this, ' +
'you\'re calling `preventDefault` on a released/nullified Synthetic event. ' +
'This is a no-op. See https://facebook.github.io/react/docs/events.html#event-pooling ' +
'for more information.'
warning(
event,
'This synthetic event is reused for performance reasons. If you\'re ' +
'seeing this, you\'re calling `preventDefault` on a ' +
'released/nullified synthetic event. This is a no-op. See ' +
'https://fb.me/react-event-pooling for more information.'
);
}
if (!event) return;
if (!event) {
return;
}

if (event.preventDefault) {
event.preventDefault();
Expand All @@ -111,14 +114,17 @@ assign(SyntheticEvent.prototype, {
stopPropagation: function() {
var event = this.nativeEvent;
if (__DEV__) {
warning(event,
'This Synthetic event is reused for performance reasons. If you\'re seeing this, ' +
'you\'re calling `stopPropagation` on a released/nullified Synthetic event. ' +
'This is a no-op. See https://facebook.github.io/react/docs/events.html#event-pooling ' +
'for more information.'
warning(
event,
'This synthetic event is reused for performance reasons. If you\'re ' +
'seeing this, you\'re calling `stopPropagation` on a ' +
'released/nullified synthetic event. This is a no-op. See ' +
'https://fb.me/react-event-pooling for more information.'
);
}
if (!event) return;
if (!event) {
return;
}

if (event.stopPropagation) {
event.stopPropagation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,33 +72,31 @@ describe('SyntheticEvent', function() {
expect(syntheticEvent.isPersistent()).toBe(true);
});

it('should warn if the Synthetic event has been released when calling `preventDefault`', function() {
it('should warn if the synthetic event has been released when calling `preventDefault`', function() {
spyOn(console, 'error');
var syntheticEvent = createEvent({});
SyntheticEvent.release(syntheticEvent);
syntheticEvent.preventDefault();
expect(console.error.calls.length).toBe(1);
expect(console.error.argsForCall[0][0]).toBe(
'Warning: ' +
'This Synthetic event is reused for performance reasons. If you\'re seeing this, ' +
'you\'re calling `preventDefault` on a released/nullified Synthetic event. ' +
'This is a no-op. See https://facebook.github.io/react/docs/events.html#event-pooling ' +
'for more information.'
'Warning: This synthetic event is reused for performance reasons. If ' +
'you\'re seeing this, you\'re calling `preventDefault` on a ' +
'released/nullified synthetic event. This is a no-op. See ' +
'https://fb.me/react-event-pooling for more information.'
);
});

it('should warn if the Synthetic event has been released when calling `stopPropagation`', function() {
it('should warn if the synthetic event has been released when calling `stopPropagation`', function() {
spyOn(console, 'error');
var syntheticEvent = createEvent({});
SyntheticEvent.release(syntheticEvent);
syntheticEvent.stopPropagation();
expect(console.error.calls.length).toBe(1);
expect(console.error.argsForCall[0][0]).toBe(
'Warning: ' +
'This Synthetic event is reused for performance reasons. If you\'re seeing this, ' +
'you\'re calling `stopPropagation` on a released/nullified Synthetic event. ' +
'This is a no-op. See https://facebook.github.io/react/docs/events.html#event-pooling ' +
'for more information.'
'Warning: This synthetic event is reused for performance reasons. If ' +
'you\'re seeing this, you\'re calling `stopPropagation` on a ' +
'released/nullified synthetic event. This is a no-op. See ' +
'https://fb.me/react-event-pooling for more information.'
);
});
});

0 comments on commit 0e2bf2f

Please sign in to comment.