fix(ajax): show the reference skeleton on every load-more surface

Clicking 加载更多 in the 多栏目文章 widget showed no skeleton at all — the
list simply stayed still until the response arrived, then the new cards
appeared. The homepage stream, archives and comments already had a working
skeleton; the widget's AJAX load goes through a different client and never
found its loader.

Root cause was DOM placement, not visibility: ContentRenderer emitted
.post_ajax_loader as a *sibling* of .widget-ajaxpager, while the widget REST
client resolves it with container.querySelector('.post_ajax_loader'). The
node existed but could never match, so .is-loading was never added and the
skeleton stayed display:none. Inactive tab panes had the same shape, and the
direct-load branch of ajaxpager() emitted no loader at all.

Changes, all following the reference theme's post_ajax() contract in
zibll/js/main.js (beforeSend anchors the loader to the end of the list;
success only hides it, never removes it):

- ContentRenderer: nest the loader inside .widget-ajaxpager for both the
  direct-load and inactive-tab branches, and drop the sibling append.
- widgets/frontend.js: anchorLoader() moves the loader to the end of the
  list before .ajax-pag on every request; appended cards are inserted before
  it; a replace preserves the node instead of wiping it with innerHTML; a
  fallback loader is created when the DOM has none; loadItems() now returns
  its promise; drop the unreachable is-loading auto-load branch.
- Message centre, user-home panels and the search page switch from spinner /
  opacity feedback to the same .posts-item-shaped skeleton, so all AJAX
  surfaces share one loading contract.
- Remove the second, never-wired skeleton system (.aksrt-skeleton-* in
  core-ui.css) and the dead spinner stylesheets/rules (skeleton.css,
  ajax-spinner.css, .load-more__*, --skeleton-base/--skeleton-shine) plus the
  unregistered assets/js/waterfall.js.
- Extend the widget, message-centre, user-home and asset-ledger contract
  tests to pin the loader inside the container, the class-only visibility
  switch, and the absence of the deleted dead code.

Verified: 470 node tests, 136 PHP widget assertions, admin-contract and
widget-system audits all green; rebuilt public assets after the CSS/JS
removals.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 22:22:15 +08:00
co-authored by Claude Fable 5
parent 271e7f0518
commit cf4554e7c8
25 changed files with 330 additions and 981 deletions
@@ -25,6 +25,43 @@ test('tab and slider renderers retain reference DOM contracts', () => {
for (const token of ['relative zib-slider', 'new-swiper slide-widget', 'swiper-wrapper', 'swiper-slide', 'slide-layer', 'data-swiper-parallax', 'swiper-button-prev', 'swiper-pagination', 'widget-slider-graphic', 'slider-col', 'cover-col', 'widget-graphic-cover']) assert.match(slider, new RegExp(token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')));
});
test('widget skeleton lives inside the AJAX container so the REST client can find it', () => {
const content = read('src/WidgetSystem/Renderers/ContentRenderer.php');
// The loader must be emitted inside .widget-ajaxpager: frontend.js resolves
// it with container.querySelector('.post_ajax_loader'). A sibling node would
// never match and no skeleton could appear on 加载更多.
assert.match(content, /\. \$loader \. '<\/div>'/);
assert.match(content, /aria-busy="false"><div class="post_ajax_loader" role="status"/);
// No pane may append the loader as a sibling of the pager.
assert.doesNotMatch(content, /\$body \.= '<div class="post_ajax_loader">'/);
});
test('widget REST client keeps the skeleton across the load-more cycle', () => {
const frontend = read('assets/widgets/frontend.js');
// Reference-parity loader switch: a class, never an inline display that
// would outrank the stylesheet and freeze the skeleton shut.
assert.match(frontend, /var loader = loaderOf\(container\) \|\| container\.appendChild\(fallbackLoader\(\)\);/);
assert.match(frontend, /loader\.classList\.add\('is-loading'\)/);
assert.doesNotMatch(frontend, /loader\.style\.display/);
// The skeleton is anchored to the end of the list on every request, exactly
// like the reference post_ajax beforeSend hook.
assert.match(frontend, /function anchorLoader\(container\) \{/);
assert.match(frontend, /if \(!loader\) return null;/);
assert.match(frontend, /pag\.parentNode\.insertBefore\(loader, pag\)/);
// Appended cards must land before the skeleton, so the skeleton always sits
// flush under the last card.
assert.match(frontend, /var anchor = loaderOf\(container\) \|\| container\.querySelector\(':scope > \.ajax-pag'\);/);
// A replace must preserve the loader node (the reference success only hides it).
assert.match(frontend, /if \(child !== loader && !child\.classList\.contains\('ajax-pag'\)\) child\.remove\(\);/);
assert.match(frontend, /return fetch\(itemsUrl\(/);
});
test('reference slider CSS includes responsive height and combo selectors', () => {
const css = read('assets/widgets/frontend.css');
const mainCss = read('assets/css/main.css');