-
-
Notifications
You must be signed in to change notification settings - Fork 18
Fix #327 -- Swith to autonomous custom element for Safari support #357
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
Apple decided they don't want to support customized built-in elements, see also: WebKit/standards-positions#97
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #357 +/- ##
==========================================
- Coverage 98.19% 97.72% -0.47%
==========================================
Files 8 8
Lines 221 264 +43
==========================================
+ Hits 217 258 +41
- Misses 4 6 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull request overview
This PR switches from customized built-in elements to autonomous custom elements to add Safari support. Apple has declined to support customized built-in elements (see WebKit standards-positions issue #97), making this change necessary for cross-browser compatibility.
- Replaces
<input is="s3-file">with<s3-file>custom element wrapper - Migrates from extending HTMLInputElement to HTMLElement with manual form participation
- Updates tests to locate elements by type rather than name, and adjusts CI configuration
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| s3file/static/s3file/js/s3file.js | Refactored S3FileInput from customized built-in to autonomous custom element, extending HTMLElement instead of HTMLInputElement, with added form participation logic and file input properties/methods |
| s3file/forms.py | Added render method to wrap Django's input HTML with s3-file custom element tags; removed is="s3-file" attribute from build_attrs |
| tests/test_forms.py | Updated test assertions to reflect new DOM structure (hidden input has no name, locate by type not name); added test for s3-file wrapper; increased Selenium timeouts; updated multi-file selector |
| tests/tests/s3file.test.js | Removed test for type property on constructor; updated connectedCallback test to verify internal _fileInput creation instead of event listener mocking |
| .github/workflows/ci.yml | Removed Chrome installation steps from Selenium test workflow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
s3file/static/s3file/js/s3file.js
Outdated
| this.form.pendingRquests = this.form?.pendingRquests || [] | ||
| this.form.pendingRquests.push(this.upload) |
Copilot
AI
Dec 18, 2025
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.
Missing optional chaining operator on first access to this.form.pendingRquests. The second access on the same line uses ?. but the first one doesn't. If this.form is null/undefined, this will throw a TypeError. Additionally, pendingRquests appears to be a typo - it should be pendingRequests (note the missing 'e').
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.
@copilot open a new pull request to apply changes based on this feedback
s3file/static/s3file/js/s3file.js
Outdated
| await Promise.all(this.form.pendingRquests) | ||
| this.form.requestSubmit(event.submitter) | ||
| this.form?.dispatchEvent(new window.CustomEvent("upload")) | ||
| await Promise.all(this.form?.pendingRquests) |
Copilot
AI
Dec 18, 2025
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.
There's a typo in the property name: pendingRquests should be pendingRequests. This appears to be a misspelling that will cause the code to wait on an undefined property, preventing proper form submission.
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.
@copilot open a new pull request to apply changes based on this feedback
s3file/forms.py
Outdated
| def render(self, name, value, attrs=None, renderer=None): | ||
| """Render the widget as a custom element for Safari compatibility.""" | ||
| return mark_safe( # noqa: S308 | ||
| str(super().render(name, value, attrs=attrs, renderer=renderer)).replace( | ||
| f'<input type="{self.input_type}"', "<s3-file" | ||
| ) | ||
| ) |
Copilot
AI
Dec 18, 2025
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.
The render method replaces the <input type="file" tag with <s3-file using a simple string replacement. This approach is fragile because it relies on the specific format of Django's rendered HTML output. If Django changes its rendering format (e.g., by changing the order of attributes or the spacing), this replacement could break. Consider using a more robust HTML parsing approach or a template-based solution.
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.
@copilot open a new pull request to apply changes based on this feedback
|
@codingjoe I've opened a new pull request, #358, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@codingjoe I've opened a new pull request, #359, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@codingjoe I've opened a new pull request, #360, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
@codingjoe I've opened a new pull request, #361, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com>
* Initial plan * Replace fragile string replacement with HTML parser for render method Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com> * Refactor HTML parser to reduce code duplication and improve documentation Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com> * Compress parser code and add comprehensive unit tests Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com> * Add test for non-file input with self-closing tag to cover line 52 Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com> * Update s3file/forms.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add entity and character reference handlers with comprehensive tests Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com> * Add tests for comment, declaration, and processing instruction handlers Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: codingjoe <1772890+codingjoe@users.noreply.github.com> Co-authored-by: Johannes Maron <johannes@maron.family> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
for more information, see https://pre-commit.ci
Apple decided they don't want to support customized built-in elements,
see also: WebKit/standards-positions#97