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

Polyfill SubmitEvent for PaleMoon #28441

Merged
merged 5 commits into from
Dec 14, 2023

Conversation

wxiaoguang
Copy link
Contributor

@wxiaoguang wxiaoguang commented Dec 12, 2023

Fix #28319

It only polyfills if there is no "SubmitEvent" class, so it has no side effect for most users.

@wxiaoguang wxiaoguang added type/enhancement An improvement of existing functionality backport/v1.21 This PR should be backported to Gitea 1.21 labels Dec 12, 2023
@wxiaoguang wxiaoguang added this to the 1.22.0 milestone Dec 12, 2023
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 12, 2023
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 12, 2023
web_src/js/utils/dom.js Outdated Show resolved Hide resolved
web_src/js/utils/dom.js Outdated Show resolved Hide resolved
web_src/js/utils/dom.js Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Dec 12, 2023
@silverwind
Copy link
Member

Maybe outsource the polyfill to https://github.com/idea2app/event-submitter-polyfill?

@silverwind
Copy link
Member

Also, I think we should create a web_src/js/polyfills.js and move existing polyfills to it, like this one for Intl.NumberFormat:

https://github.com/go-gitea/gitea/blob/main/web_src/js/webcomponents/polyfill.js

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented Dec 12, 2023

Maybe outsource the polyfill to https://github.com/idea2app/event-submitter-polyfill?

No, event-submitter-polyfill has many problems. The biggest problem is that IIRC PaleMoon doesn't seem having addEventListener(capture) support.

Also, I think we should create a web_src/js/polyfills.js and move existing polyfills to it, like this one for Intl.NumberFormat:

No, it's not feasible at the moment. Our polyfill patch needs some dependencies between functions. For example, the _submitter, and the index.js code needs to call a helper function. Putting the code together is more maintainable. If you put the code into the webcomponents/polyfill.js, then some polyfill code appears in the webcomponents.js, some polyfill code appears in index.js, it's difficult to read or maintain.


image

@silverwind
Copy link
Member

If you put the code into the webcomponents/polyfill.js, then some polyfill code appears in the webcomponents.js, some polyfill code appears in index.js, it's difficult to read or maintain.

Not into webcomponents, but a separate polyfill file in the root. If polyfills are spread out in the code base, it will be harder to remove them later. Prefer to have them all in one file. Ideally only export functions from that file. Can be either ponyfills or polyfills.

@wxiaoguang
Copy link
Contributor Author

If polyfills are spread out in the code base, it will be harder to remove them later.

This polyfill is special, it already "spreads" because there is no transparent approach, the callers have directly dependency with this change. So I do not see it's worth to move the code again.

If you have better ideas, feel free to edit this PR directly, I do not see necessary changes at the moment.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 14, 2023
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Dec 14, 2023
@lunny lunny merged commit 6632d14 into go-gitea:main Dec 14, 2023
25 checks passed
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Dec 14, 2023
@GiteaBot GiteaBot added backport/done All backports for this PR have been created and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Dec 14, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Dec 15, 2023
* giteaofficial/main:
  Polyfill SubmitEvent for PaleMoon (go-gitea#28441)
  Fix Chinese translation of config cheat sheet[API] (go-gitea#28472)
  Add combined index for issue_user.uid and issue_id (go-gitea#28080)
  Fix documents for "custom/public/assets/" (go-gitea#28465)
  Only use SHA256 feature when git >= 2.42 (go-gitea#28466)
@wxiaoguang wxiaoguang deleted the fix-palemoon-submitter branch December 15, 2023 03:00
wxiaoguang added a commit that referenced this pull request Dec 15, 2023
Backport #28441 by wxiaoguang

Fix #28319

It only polyfills if there is no "SubmitEvent" class, so it has no side
effect for most users.

Co-authored-by: wxiaoguang <[email protected]>
fuxiaohei pushed a commit to fuxiaohei/gitea that referenced this pull request Jan 17, 2024
silverwind pushed a commit to silverwind/gitea that referenced this pull request Feb 20, 2024
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created backport/v1.21 This PR should be backported to Gitea 1.21 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Browsers without SubmitEvent.submitter support don't work with form-fetch-action mechanism well
5 participants