Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(chore) - remove focusElement #1548

Merged
merged 7 commits into from Apr 29, 2019
Merged

(chore) - remove focusElement #1548

merged 7 commits into from Apr 29, 2019

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Apr 17, 2019

Adding items in react: https://codesandbox.io/s/748j0p3jpj
Swapping in react: https://codesandbox.io/s/olq48z68r5

So the first we should support, which also feels obviosu to me personally but the second not so much.

The odd thing is that it only fails when you insert a second thing above

So add one before --> works
Add one after --> works
Add one after previous --> works
Add one after the first step --> fails

Size of core stays the same
Seems to give a significant performance increase

@JoviDeCroock
Copy link
Member Author

Don't take the Passing as it succeeds I have adjusted this in tests:
https://github.com/developit/preact/pull/1548/files#diff-4860f971b6d2f661624c4d35fbba8cc3L106

Now it effectively tests with keys.

Without keys it loses focus when the last insertion happens so insert 0 before 1.
Then we treat input like a new element, logging output:

LOG: 'parent before', <div><span>0</span><input type="text"><span>1</span><span>3</span></div>, <input type="text">, <span>3</span>
LOG: 'parent append', <span></span>, 3
LOG: 'parent append', <div><span>0</span><span>1</span><input type="text"><span>2</span></div>, <span>3</span>

'parent before' is first the existing parentDom and then adding a newDom before given oldDom
'parent append' adds the second argument to the first

@JoviDeCroock JoviDeCroock marked this pull request as ready for review April 28, 2019 13:11
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 6617c7f on chore/bundleSize into cc4b770 on master.

src/diff/children.js Outdated Show resolved Hide resolved
Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's finally gone 🙌 Really appreciate that you went through and battled all the nitty gritty details! That's some impressive work here 💯

@JoviDeCroock JoviDeCroock merged commit 9d2fb10 into master Apr 29, 2019
@JoviDeCroock JoviDeCroock deleted the chore/bundleSize branch April 29, 2019 05:25
@ForsakenHarmony
Copy link
Member

🎉

lordvlad added a commit to lordvlad/preact that referenced this pull request Apr 30, 2019
* upstream/master: (341 commits)
  Revert "Simplify originalDom check (-4 B)
"
  Simplify originalDom check (-4 B)
  Add back mistakenly removed JSDoc comment
  Remove unnecessary code from `diffChildren` (-16 B)
  Golf createContext (-6 B)
  Fix useContext test spacing
  Remove `dom` parameter from `diff()` (-11 B)
  Move all component diff'ing logic into component diff condition (-6 B)
  fix issue by marking dirty before .render since this can potentially add another entry on the render queue
  add relevant test
  (chore) - remove focusElement (preactjs#1548)
  Update type definition (preactjs#1581)
  Compress code, assume EMPTY_OBJ._children == null
  Refactor out variables from diffChildren
  Compress diffChildren further
  Compress diffChildren further
  Condense code in diffChildren
  Fix infinite loop because of props mutation (preactjs#1577)
  (fix) - Error boundary not applying in array cases (preactjs#1572)
  Add styled-components example (preactjs#1574)
  ...

# Conflicts:
#	.eslintignore
#	compat/mangle.json
#	compat/src/index.js
#	compat/src/internal.d.ts
#	debug/mangle.json
#	hooks/src/index.d.ts
#	hooks/src/index.js
#	hooks/src/internal.d.ts
#	mangle.json
#	package.json
#	src/component.js
#	src/constants.js
#	src/create-context.js
#	src/create-element.js
#	src/diff/children.js
#	src/diff/index.js
#	src/diff/props.js
#	src/index.d.ts
#	src/internal.d.ts
#	src/jsx.d.ts
#	src/render.js
#	src/util.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants