This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Remove react and add preact #13608
Merged
Merged
Remove react and add preact #13608
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ab946df
Add Preact library
boopeshmahendran 99c130e
Change react to preact
boopeshmahendran 504cdf4
Fix problems caused by replacing react with preact
boopeshmahendran 6c5c5b8
Add Preact test utils and dependencies
boopeshmahendran a7d197e
Change requires from react to preact in FileTreeView-test
boopeshmahendran 9e8ec14
Fix problems caused by replacing react test utils with preact test utils
boopeshmahendran 398abb2
Remove react
boopeshmahendran a498327
Make findRenderedDOMComponentWithTag function as helper function
boopeshmahendran 940a054
Find and Replace react with preact
boopeshmahendran ad83fdf
Make preact, preact-compat, preact-test-utils as node_modules
boopeshmahendran fa08b21
Change preact-compat dependency to point to adobe's fork
boopeshmahendran 089fb7a
Merge branch 'master' into convertReactToPreact
swmitra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,8 @@ | |
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
var React = require("thirdparty/react"), | ||
ReactDOM = require("thirdparty/react-dom"), | ||
var React = require("thirdparty/preact"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably should just |
||
ReactDOM = require("thirdparty/preact"), | ||
Classnames = require("thirdparty/classnames"), | ||
Immutable = require("thirdparty/immutable"), | ||
_ = require("thirdparty/lodash"), | ||
|
@@ -219,6 +219,7 @@ define(function (require, exports, module) { | |
|
||
var node = this.refs.name; | ||
node.setSelectionRange(0, _getName(fullname, extension).length); | ||
node.focus(); // set focus on the rename input | ||
ViewUtils.scrollElementIntoView($("#project-files-container"), $(node), true); | ||
}, | ||
|
||
|
@@ -480,6 +481,11 @@ define(function (require, exports, module) { | |
extension = LanguageManager.getCompoundFileExtension(fullname), | ||
name = _getName(fullname, extension); | ||
|
||
// React automatically wraps content in a span element whereas preact doesn't, so do it manually | ||
if (name) { | ||
name = DOM.span({}, name); | ||
} | ||
|
||
if (extension) { | ||
extension = DOM.span({ | ||
className: "extension" | ||
|
@@ -601,6 +607,7 @@ define(function (require, exports, module) { | |
|
||
var node = this.refs.name; | ||
node.setSelectionRange(0, fullname.length); | ||
node.focus(); // set focus on the rename input | ||
ViewUtils.scrollElementIntoView($("#project-files-container"), $(node), true); | ||
}, | ||
|
||
|
@@ -758,11 +765,16 @@ define(function (require, exports, module) { | |
parentPath: this.props.parentPath | ||
}); | ||
} else { | ||
// React automatically wraps content in a span element whereas preact doesn't, so do it manually | ||
if (this.props.name) { | ||
var name = DOM.span({}, this.props.name); | ||
} | ||
|
||
// Need to flatten the arguments because getIcons returns an array | ||
var aArgs = _.flatten([{ | ||
href: "#", | ||
className: directoryClasses | ||
}, thickness, this.getIcons(), this.props.name]); | ||
}, thickness, this.getIcons(), name]); | ||
nameDisplay = DOM.a.apply(DOM.a, aArgs); | ||
} | ||
|
||
|
@@ -1035,11 +1047,11 @@ define(function (require, exports, module) { | |
|
||
return DOM.div( | ||
null, | ||
contents, | ||
selectionBackground, | ||
contextBackground, | ||
extensionForSelection, | ||
extensionForContext, | ||
contents | ||
extensionForContext | ||
); | ||
} | ||
})); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
define (function(require, exports, module){ | ||
'use strict'; | ||
|
||
module.exports = `onKeyDown onKeyPress onKeyUp onFocus onBlur onClick onContextMenu onDoubleClick onDrag onDragEnd onDragEnter onDragExit onDragLeave onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave onMouseMove onMouseOut onMouseOver onMouseUp onChange onInput onSubmit onTouchCancel onTouchEnd onTouchMove onTouchStart onLoad onError onAnimationStart onAnimationEnd onAnimationIteration onTransitionEnd`.split(' ').map(item => { | ||
const event = item.replace('on', ''); | ||
return event.charAt(0).toLowerCase() + event.substr(1); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably add
preact
as annode_module
instead of inlining it to thethirdparty
folder as we have been doing with new dependencies. (related to #12006)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petetnt Actually react is being replaced with preact to remove facebook dependencies due to the PATENT issues. But preact-compat uses prop-types which is by facebook and we do not use proptypes in the
FileTreeView
code, so I removed it manually from preact-compat. So only we are inlining it to thethirdparty
folder.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, wasn't aware that
compat
usesprop-types
package as-is