Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Remove atom-space-pen-views and custom elements - #1032

Merged
as-cii merged 20 commits into
masterfrom
as-remove-jquery
Mar 3, 2017
Merged

as-cii merged 20 commits into
masterfrom
as-remove-jquery

Conversation

@as-cii

@as-cii as-cii commented Feb 6, 2017 •

Copy link
Copy Markdown
Contributor

This pull request replaces atom-space-pen-views with manual DOM manipulation. It also changes DirectoryView and FileView so that they don't register themselves as custom elements, but are simple JavaScript objects managing a DOM element. Feature-wise nothing should change, but this will help remove jQuery from Atom.

/cc: @ungb for 👀

@as-cii

as-cii commented Feb 6, 2017

Copy link
Copy Markdown
Contributor Author

@ungb: some things in this pull request that might be worth testing 💭

  1. Drag-and-dropping files.
  2. Drag-and-dropping directories.
  3. Drag-and-dropping project roots.
  4. Keyboard navigation.
  5. Mouse navigation.
  6. Interactions with third-party packages.
  7. Tree-view commands in the Command Palette.

Comment thread lib/tree-view.coffee Outdated
isRecursive = e.altKey or false
@selectEntry(entry)
if entry instanceof DirectoryView
if entry.classList.contains('directory')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This raises an exception if the user clicks on the tree-view's background, rather than a specific entry:

tree-view.coffee [sm]:225
Uncaught TypeError: Cannot read property 'classList' of null
	module.exports.TreeView.entryClicked  @ tree-view.coffee [sm]:225
	(anonymous function)                  @ tree-view.coffee [sm]:100

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much for the heads-up! Fixed in 31c472d. 👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Haha, my pleasure! I'm running latest changes through Mocha over and again, so it's easy to spot when something breaks. =)

@Ben3eeE

Ben3eeE commented Feb 6, 2017

Copy link
Copy Markdown
Contributor

tree-view:show-in-file-manager and tree-view:show-current-file-in-file-manager opens the Documents folder instead of the folder of the selected/current file. I am on Windows 10 Atom 1.14.0-beta4 ia32

@Alhadis

Alhadis commented Feb 9, 2017

Copy link
Copy Markdown
Contributor

seti-ui threw an error after I enabled it, and it was one of the errors I fixed to get file-icons future-proof:

Figure 1

Might be worth shimming on and having Grim issue a deprecation notice for users.

@as-cii

as-cii commented Feb 9, 2017

Copy link
Copy Markdown
Contributor Author

Thanks again for the amazing feedback and for providing a fix on the seti-ui package, @Alhadis. Your help is really appreciated! ✨

I am on the fence about shimming because it seems like it could be non-trivial to provide a compatible interface. In particular, there are a lot of jQuery methods that might be called from third-party packages and re-implementing them by using DOM primitives could take long, other than being potentially inaccurate.

An alternative might be to use a Proxy object and forward all the unknown methods to jQuery but, again, I am not entirely sure that would be the best path forward. Maybe we should let this bake for a while on beta until everyone has the chance to transition away from jQuery APIs? Most of the time the fix will be trivial for package authors and we could also write a blog post informing everyone about the change.

@Alhadis

Alhadis commented Feb 9, 2017 •

Copy link
Copy Markdown
Contributor

Oh, I was only talking about shimming the tree-view's on method, since it has the greatest change of being tampered with by package authors (*cough* …guilty as charged). In which case, it's just a simple matter of Object.defineProperty(treeView.scroller, "on", {value(event, fn){ return this.addEventListener(event, fn); }});, or something similar.

To be honest, breakage will probably get packages fixed quicker than deprecation notices. That is, if the speed at which seti-ui removed their shadow DOM selectors is anything to go by... (6 days ago)

I'm probably biased, I just want jQuery to go away as quickly as possible.

@as-cii

as-cii commented Feb 9, 2017

Copy link
Copy Markdown
Contributor Author

Oh, I was only talking about shimming the tree-view's on method, since it has the greatest change of being tampered with by package authors (cough …guilty as charged). In which case, it's just a simple matter of Object.defineProperty(treeView.scroller, "on", {value(event, fn){ return this.addEventListener(event, fn); }});, or something similar.

Yeah, my main concern with that is that we would also need to wrap the DOM event inside a jQuery event object and give users a way of providing a selector as the second parameter of the on call. We would also need to do something similar on the tree-view object itself, as well as on other internals of the tree-view package.

To be honest, breakage will probably get packages fixed quicker than deprecation notices. That is, if the speed at which seti-ui removed their shadow DOM selectors is anything to go by... (6 days ago)

Agreed. I also think that the number of packages affected by this is actually low, so it might be worth seeing what happens on beta and then decide whether a shim is worth it or not. 👍

@Alhadis

Alhadis commented Feb 9, 2017

Copy link
Copy Markdown
Contributor

Oh right, I completely forgot about the [0] part as well... uggggh, yeah, you're right, screw it. Not worth the complexity, and authors should've been using documented APIs in the first place. 😀

Comment thread lib/tree-view.coffee
openSelectedEntry: (options={}, expandDirectory=false) ->
selectedEntry = @selectedEntry()
if selectedEntry instanceof DirectoryView
if selectedEntry.classList.contains('directory')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will break when nothing is selected, because selectedEntry is null.

Happened after I hit Enter with focus on the tree-view by mistake.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a7e7be1. @Alhadis: thanks so much for finding these pesky regressions! ⚡️

@ungb

ungb commented Mar 1, 2017

Copy link
Copy Markdown
Contributor

Looks good to me, but I'm also seeing the same issue @Alhadis is with seti-ui, I wonder if this will cause other breakages for other packages. We can maybe put it out on beta and use bugsnag to capture more exceptions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants