From 5f741e84613ccc1a376b520a0961792686a17c1f Mon Sep 17 00:00:00 2001 From: Daniel van Hoesel Date: Fri, 29 Sep 2017 09:54:38 +0200 Subject: [PATCH] Make sure UglifyJS works Fixes #110 --- demo/package.json | 3 +++ package.json | 2 +- src/SyntheticEvent.js | 32 ++++++++++++++++---------------- src/TapEventPlugin.js | 20 ++++++++++---------- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/demo/package.json b/demo/package.json index 13469ff3b3eca..e1b63c7d2f63c 100644 --- a/demo/package.json +++ b/demo/package.json @@ -3,13 +3,16 @@ "version": "0.0.1", "devDependencies": { "browserify": "11.2.0", + "envify": "4.1.0", "react": "^16.0.0-0", "react-dom": "^16.0.0-0", "react-tap-event-plugin": "../", + "uglifyify": "4.0.4", "watchify": "3.9.0" }, "scripts": { "build": "browserify src/application.js -o application.js", + "dist": "NODE_ENV=production browserify -t envify -g uglifyify src/application.js -o application.js", "watch": "watchify src/application.js -o application.js -v" }, "dependencies": {} diff --git a/package.json b/package.json index 4eafa00286b60..f75d054ff2e12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-tap-event-plugin", - "version": "3.0.0", + "version": "3.0.1", "description": "Facebook's TapEventPlugin, temporarily available on npm until its made public in their repo", "main": "src/injectTapEventPlugin.js", "files": [ diff --git a/src/SyntheticEvent.js b/src/SyntheticEvent.js index 55ddb79db5f51..a21530e7b8260 100644 --- a/src/SyntheticEvent.js +++ b/src/SyntheticEvent.js @@ -31,7 +31,7 @@ var shouldBeReleasedProperties = [ 'isDefaultPrevented', 'isPropagationStopped', '_dispatchListeners', - '_dispatchInstances', + '_dispatchInstances' ]; /** @@ -50,7 +50,7 @@ var EventInterface = { return event.timeStamp || Date.now(); }, defaultPrevented: null, - isTrusted: null, + isTrusted: null }; /** @@ -75,7 +75,7 @@ function SyntheticEvent( dispatchConfig, targetInst, nativeEvent, - nativeEventTarget, + nativeEventTarget ) { if (__DEV__) { // these have a getter/setter for warnings @@ -182,7 +182,7 @@ Object.assign(SyntheticEvent.prototype, { Object.defineProperty( this, propName, - getPooledWarningPropertyDefinition(propName, Interface[propName]), + getPooledWarningPropertyDefinition(propName, Interface[propName]) ); } else { this[propName] = null; @@ -195,20 +195,20 @@ Object.assign(SyntheticEvent.prototype, { Object.defineProperty( this, 'nativeEvent', - getPooledWarningPropertyDefinition('nativeEvent', null), + getPooledWarningPropertyDefinition('nativeEvent', null) ); Object.defineProperty( this, 'preventDefault', - getPooledWarningPropertyDefinition('preventDefault', emptyFunction), + getPooledWarningPropertyDefinition('preventDefault', emptyFunction) ); Object.defineProperty( this, 'stopPropagation', - getPooledWarningPropertyDefinition('stopPropagation', emptyFunction), + getPooledWarningPropertyDefinition('stopPropagation', emptyFunction) ); } - }, + } }); SyntheticEvent.Interface = EventInterface; @@ -259,15 +259,15 @@ if (__DEV__) { "This synthetic event is reused for performance reasons. If you're " + "seeing this, you're adding a new property in the synthetic event object. " + 'The property is never released. See ' + - 'https://fb.me/react-event-pooling for more information.', + 'https://fb.me/react-event-pooling for more information.' ); didWarnForAddedNewProperty = true; } target[prop] = value; return true; - }, + } }); - }, + } }); /*eslint-enable no-func-assign */ } @@ -289,7 +289,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) { return { configurable: true, set: set, - get: get, + get: get }; function set(val) { @@ -317,7 +317,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) { 'See https://fb.me/react-event-pooling for more information.', action, propName, - result, + result ); } } @@ -331,7 +331,7 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { dispatchConfig, targetInst, nativeEvent, - nativeInst, + nativeInst ); return instance; } @@ -339,7 +339,7 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { dispatchConfig, targetInst, nativeEvent, - nativeInst, + nativeInst ); } @@ -347,7 +347,7 @@ function releasePooledEvent(event) { var EventConstructor = this; invariant( event instanceof EventConstructor, - 'Trying to release an event instance into a pool of a different type.', + 'Trying to release an event instance into a pool of a different type.' ); event.destructor(); if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { diff --git a/src/TapEventPlugin.js b/src/TapEventPlugin.js index 77d1675d5b00c..4fd18045d1ee2 100644 --- a/src/TapEventPlugin.js +++ b/src/TapEventPlugin.js @@ -35,7 +35,7 @@ var startCoords = {x: 0, y: 0}; var Axis = { x: {page: 'pageX', client: 'clientX', envScroll: 'currentPageScrollLeft'}, - y: {page: 'pageY', client: 'clientY', envScroll: 'currentPageScrollTop'}, + y: {page: 'pageY', client: 'clientY', envScroll: 'currentPageScrollTop'} }; function getAxisCoordOfEvent( @@ -54,7 +54,7 @@ function getDistance(coords, nativeEvent) { var pageY = getAxisCoordOfEvent(Axis.y, nativeEvent); return Math.pow( Math.pow(pageX - coords.x, 2) + Math.pow(pageY - coords.y, 2), - 0.5, + 0.5 ); } @@ -62,21 +62,21 @@ var touchEvents = [ 'topTouchStart', 'topTouchCancel', 'topTouchEnd', - 'topTouchMove', + 'topTouchMove' ]; var dependencies = ['topMouseDown', 'topMouseMove', 'topMouseUp'].concat( - touchEvents, + touchEvents ); var eventTypes = { touchTap: { phasedRegistrationNames: { bubbled: 'onTouchTap', - captured: 'onTouchTapCapture', + captured: 'onTouchTapCapture' }, - dependencies: dependencies, - }, + dependencies: dependencies + } }; var usedTouchTime = 0; @@ -92,7 +92,7 @@ function createTapEventPlugin(shouldRejectClick) { topLevelType, targetInst, nativeEvent, - nativeEventTarget, + nativeEventTarget ) { if (!isStartish(topLevelType) && !isEndish(topLevelType)) { return null; @@ -114,7 +114,7 @@ function createTapEventPlugin(shouldRejectClick) { eventTypes.touchTap, targetInst, nativeEvent, - nativeEventTarget, + nativeEventTarget ); } if (isStartish(topLevelType)) { @@ -126,7 +126,7 @@ function createTapEventPlugin(shouldRejectClick) { } EventPropagators.accumulateTwoPhaseDispatches(event); return event; - }, + } }; }