Skip to content

Remove jQuery UI from form-mini.js #14273

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

Conversation

jonathanKingston
Copy link
Contributor

@jonathanKingston jonathanKingston commented Mar 22, 2018

Description

Removal of jQuery UI from the form search as it's a dependency that isn't needed.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Mar 23, 2018

Hi @jonathanKingston,

Could you clarify what is benefit of getting rid of jquery ui specially in this place? AFAIK jquery UI is using in a lot of places, so removing it just from one place - do not changing anything. Not sure if it's reasonable to accept such pull request. Actually previous implementation was much better because there were using constants

@jonathanKingston
Copy link
Contributor Author

@ihor-sviziev the idea is to burn down the implementation areas of jQuery UI. Given the jQuery UI version is old and insecure. The jQuery UI version is also modified making it hard to upgrade.
As this is probably the most common usage, I started here so I could answer this question.

Actually previous implementation was much better because there were using constants

Seems fair, I mean it might make sense to have a lightweight jQuery plugin which just handles keydown events etc, however I didn't spot many other areas that would use it.

@jonathanKingston
Copy link
Contributor Author

jonathanKingston commented Mar 23, 2018

Minus TinyMCE and some other libraries it looks like it could be removed in another PR in the front-end. I could expand this commit to do that? The only thing I am uncertain of is the use of mage/calendar

Copy link
Contributor

@VladimirZaets VladimirZaets left a comment

Choose a reason for hiding this comment

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

Currently, we can't use event.key without the fallback to the old approach because we supporting IE11 and Edge browsers and there aren't fully support event.key.
https://caniuse.com/#feat=keyboardevent-key
Also, if you want you can read more about it https://medium.com/@uistephen/keyboardevent-key-for-cross-browser-key-press-check-61dbad0a067a

@jonathanKingston
Copy link
Contributor Author

Also, if you want you can read more about it https://medium.com/@uistephen/keyboardevent-key-for-cross-browser-key-press-check-61dbad0a067a

Damn sounds like MDN docs are wrong on the support for this sorry.

Anyway I still think this would be easier to copy out the jQuery UI behaviour for keypresses into a smaller lib as the only other potential jQuery UI on the front end I have found is the calendar meaning in a follow up we could remove it as a FE dependency. Does that sound like an ok solution @VladimirZaets?

@orlangur
Copy link
Contributor

Hi @jonathanKingston,

the idea is to burn down the implementation areas of jQuery UI

While me personally would love to get rid of jQuery/jQuery UI completely (in favor of Angular, but it's not gonna happen :D), how is it even possible considering http://devdocs.magento.com/guides/v2.2/javascript-dev-guide/widgets/jquery-widgets-about.html?

So, to reduce jQuery UI usages some common strategy should be agreed first which then should be concretized in particular action points.

Given the jQuery UI version is old and insecure

Are there any attack vectors you know of actually affecting Magento?

The jQuery UI version is also modified making it hard to upgrade

Having backward compatibility in mind, this seems the only viable approach though.

@orlangur orlangur self-assigned this Mar 23, 2018
@jonathanKingston
Copy link
Contributor Author

Are there any attack vectors you know of actually affecting Magento?

Not at the moment, however having very old versions is never good. I wasn't raising this as a vuln or anything, just that there might be attack vectors. I also haven't tried to look into the exploits in UI and match them to Magento.

Having backward compatibility in mind, this seems the only viable approach though.

I think at this point if the front end can have the code removed then this will help update or removal. I'm also not 100% on how you handle backwards compatibility either.

how is it even possible considering http://devdocs.magento.com/guides/v2.2/javascript-dev-guide/widgets/jquery-widgets-about.html?

Only the following appear to use UI though:

Also "Magento out of the box does not contain jQuery UI styles", so it really does seem like these small number of references that could be burned down in a few PRs.

So, to reduce jQuery UI usages some common strategy should be agreed first which then should be concretized in particular action points.

Yeah we have @dmanners at the office today, he said we should have a conversation about architectural changes with the relevant parties :)

@orlangur
Copy link
Contributor

Only the following appear to use UI though:

My main concern is http://devdocs.magento.com/guides/v2.0/coding-standards/code-standard-jquery-widgets.html, there are almost 300 occurrences of $.widget in Magento Open Source. But probably something like "it might make sense to have a lightweight jQuery plugin" is possible for widgets too.

we should have a conversation about architectural changes with the relevant parties :)

Great!

@jonathanKingston jonathanKingston force-pushed the 2.3-develop_remove-jquery-ui-from-form-mini branch from 2b161f8 to 1858391 Compare March 24, 2018 11:03
@jonathanKingston
Copy link
Contributor Author

there are almost 300 occurrences of $.widget in Magento Open Source. But probably something like "it might make sense to have a lightweight jQuery plugin" is possible for widgets too.

Yeah I think we can migrate that to something simpler too.

@orlangur I updated the PR to include a function from an external file, I moved another usage in a different file also.

@orlangur
Copy link
Contributor

orlangur commented Jun 4, 2018

@VladimirZaets please take a look on this one.

@ihor-sviziev ihor-sviziev removed their request for review June 5, 2018 07:40
@ishakhsuvarov ishakhsuvarov added this to the Release: 2.3.1 milestone Sep 18, 2018
@VladimirZaets
Copy link
Contributor

@jonathanKingston

Anyway I still think this would be easier to copy out the jQuery UI behaviour for keypresses into a smaller lib as the only other potential jQuery UI on the front end I have found is the calendar meaning in a follow up we could remove it as a FE dependency. Does that sound like an ok solution @VladimirZaets?

It's make sense. But we already have small library that transform keycodes to understandable type.

So, we can use this library in current case, but we shouldnt create new one library with the similiar behaviour

@jonathanKingston
Copy link
Contributor Author

I'm not working on this any longer, I'm just going to close my PRs. Feel free to adopt the code after a fix-up etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants