Trac: Refresh the Trac front-end assets - #755
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
Refreshes Trac front-end assets (JS/CSS + Trac templates) by consolidating the former Jinja2-compat shim into the main assets, modernizing markup construction to avoid unsafe HTML string concatenation, and removing dead client code.
Changes:
- Refactors
wp-trac.jsto build DOM nodes / escape element content where needed, and adds several Trac UI/UX tweaks (auth links, notices, report/query behaviors). - Updates
wp-trac.cssto absorb the removed compat stylesheet and modernizes selectors/values. - Removes unused legacy assets (
wp-trac-jinja-compat.*,trac-search.js) and updates template includes accordingly.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| wordpress.org/public_html/style/trac/wp-trac.js | Main Trac behavior script: refactors HTML construction/escaping, adds UI behaviors, removes reliance on compat shim. |
| wordpress.org/public_html/style/trac/wp-trac.css | Consolidates/modernizes Trac styling; absorbs compat CSS behavior and updates selectors/weights. |
| wordpress.org/public_html/style/trac/wp-trac-jinja-compat.js | Removed legacy Jinja2-compat client rewrite shim. |
| wordpress.org/public_html/style/trac/wp-trac-jinja-compat.css | Removed legacy Jinja2-compat stylesheet. |
| wordpress.org/public_html/style/trac/trac-security.js | Reformats and updates security-keyword gating UI on /newticket. |
| wordpress.org/public_html/style/trac/trac-search.js | Removed dead related-ticket search script. |
| trac.wordpress.org/templates/site_head.html | Stops loading removed compat CSS. |
| trac.wordpress.org/templates/site_footer.html | Stops loading removed compat JS and updates jQuery AJAX callback to .done(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Brings trac/ in line with the formatting and lint rules from WordPress#734, ahead of that PR, so the same files do not need touching again when it lands and the assets only need deploying once. Retires the jinja2 compatibility shim: its rules now live in wp-trac.css and the templates no longer load the removed script and stylesheet. trac-search.js goes with it, unused since its include was removed in r7275. Builds markup through the DOM rather than by string concatenation in the attachment preview, the reopen notice, the non-gardener type field and the attachment autocomplete, and restores the preserved attribute matches by index so a comment cannot shift the restore queue. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
8948750 to
0767d83
Compare
encloseSelection() is handed a raw DOM element from $textarea[0], and uses setSelectionRange/selectionStart/value on it throughout. The jQuery-style textarea.trigger( 'focus' ) therefore threw a TypeError and broke the PHP code block toolbar button; restores textarea.focus(). .atwho-view .cur strong declared `font: 700`, which is not a valid font shorthand — it requires at least a size and a family — so browsers dropped the declaration. Uses font-weight instead. Points the security reporting handbook link at HTTPS. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (2)
wordpress.org/public_html/style/trac/wp-trac.css:433
- The removed
wp-trac-jinja-compat.csspreviously hid both#tab_advancedand#tab_keybindings. If the intent is to keep the same Preferences tabs behavior ("#tabs carried over" in the PR description),#tab_keybindingsshould be hidden here as well.
/* Sessions are tied to WP.org logins; hide the anonymous "Advanced" session tab. */
#content.prefs #tabs #tab_advanced {
display: none;
}
wordpress.org/public_html/style/trac/wp-trac.css:1671
- Missing comma at the end of this selector line causes the selector list to be parsed incorrectly, so the bbPress hover color rule won’t apply as intended.
body.bbpress #content.build h2.config :visited
The preferences tab rule hid both #tab_advanced and #tab_keybindings; only the first survived the merge, so the Keyboard Shortcuts tab became visible again. The attachment form hid its "Replace existing attachment of the same name" options from non-gardeners, keyed off a body class that the removed shim set. wp-trac.js already tracks gardener status, so it sets the class instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The refreshed file matched the scripts_version query instead, which armed a function that had never fired. $.loadStyleSheet then requested Trac's own stylesheets at URLs the page had not loaded, so a second copy of trac.css was appended after wp-trac.css and Trac's rules won the cascade — visible as fieldset shadows and unstyled toolbar buttons returning on comment preview. Matching `v=` again restores the previous behaviour. Busting only the dynamic loads would not have fixed caching regardless: Trac emits those stylesheet links unversioned from htdocs_location, so the cached copy still paints first. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1f08ebd to
f4aafb5
Compare
Trac's wikitoolbar.js gave each button an id up to 1.0.9, which is what these rules and the PHP button's insertion point were written against. Since 1.6 it sets `class="trac-wikitoolbar-<type>"` and no id, so every dashicon rule matched nothing and the buttons rendered as empty boxes, and `find( '#code' ).after()` had nothing to attach to, so the PHP code block button was never added at all. The `#code-php` rule stays as it is; that id is one we set ourselves. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.
Suppressed comments (1)
wordpress.org/public_html/style/trac/trac-security.js:81
has_overlap()intends to strip non-letter characters before splitting into words, but the character class/[^a-z|\s]/gaccidentally allows the|character (because|is literal inside[]). This can prevent detection when users paste payload-like strings containing|separators.
has_overlap( str, arr ) {
const words = str
.toLowerCase()
.replace( /[^a-z|\s]/g, '' )
.split( ' ' ),
overlap = this.intersect( words, arr );
Takes the
style/trac/and template changes from #734 ahead of it, with fixes on top, so these assets deploy once and #734 shrinks to its build tooling.From #734:
trac/*.jsandwp-trac.cssreformatted; the jinja2 shim retired, its rules folded intowp-trac.css(verified#banner,#footer,#tabs);trac-search.jsremoved, dead since r7275;.success()→.done(). Excludes the build tooling andtrac/README.md, which documents scripts that only exist once #734 lands.Markup construction.
.text(),.attr()and.val()decode entities, so values read back out of the DOM are not safe to concatenate into markup.postPreviewHacks(),nonGardeners(), the closed-milestone notice and the attachment autocomplete now build nodes or escape.linkMentions()/linkGutenbergIssues()index their placeholder tokens, which a comment containing the literal__PLACEHOLDER__could previously desynchronise. The two existing$( '<span />' ).text( … ).html()uses become a namedescapeHtml(), element-content only.Defects found along the way
textarea.trigger( 'focus' )threw on a DOM element, silently breaking the PHP code block button.class="trac-wikitoolbar-<type>", so icons rendered as empty boxes and the button was never inserted. Pre-existing.#tab_keybindingsand the non-gardener attachment-options rule. Both restored.addDynamicAssetCacheBuster()toscripts_version, arming a function that had never fired.$.loadStyleSheetde-dupes on exact href, so a secondtrac.csslanded afterwp-trac.cssand Trac's rules won. Restored tov=.font: 700→font-weight; handbook link to HTTPS.Deployment: sandbox deploy of
s.w.org/style/trac/, then bumpscripts_versionin bothsite_head.htmlandsite_footer.html.🤖 Generated with Claude Code