fix: init robuste avant <body>, pas de repli tardif au-dessus de l'écran, README

- écoute freshrss:load-more sur document (script async possiblement exécuté
  avant le parsing de <body>)
- ne replie jamais après coup un article qui commence au-dessus de l'écran :
  la page sauterait et des articles non vus seraient marqués lus
- README : l'image officielle n'a pas git, installation depuis l'hôte

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Vincent BourdonandClaude Opus 5.5 committed 2026-11-06 19:15:54 +01:00
1 parent ccb230d514
commit 66d997cc6e
4 files changed
+66 -10

No files matched your search

+37
View File
@@ -143,3 +143,40 @@ test('init handles load-more', () => {
assert.equal(document.querySelectorAll('.read-more-btn').length, 2);
assert.equal(document.getElementById('flux_2').dataset.readMore, 'collapsed');
});
test('init works before body is parsed', () => {
const { window, document, ReadMore } = setup([]);
document.documentElement.removeChild(document.body);
setContext(window, 'reader');
assert.doesNotThrow(() => ReadMore.init(window, measure));
const body = document.createElement('body');
body.innerHTML = entry(1, 1000);
document.documentElement.appendChild(body);
body.dispatchEvent(new window.Event('freshrss:load-more', { bubbles: true }));
assert.equal(document.getElementById('flux_1').dataset.readMore, 'collapsed');
});
test('late image load does not collapse entry already above viewport top', () => {
const { window, document, ReadMore } = setup([entry(1, 300)]);
setContext(window, 'reader');
ReadMore.init(window, measure);
const flux = document.getElementById('flux_1');
flux.getBoundingClientRect = () => ({ top: -100, bottom: 200 });
const text = flux.querySelector('.text');
text.dataset.h = '1000';
text.querySelector('img').dispatchEvent(new window.Event('load'));
assert.ok(!text.classList.contains('read-more-collapsed'));
assert.equal(flux.querySelectorAll('.read-more-btn').length, 0);
});
test('load-more does not collapse short entry already above viewport top', () => {
const { window, document, ReadMore } = setup([entry(1, 300)]);
setContext(window, 'reader');
ReadMore.init(window, measure);
const flux = document.getElementById('flux_1');
flux.getBoundingClientRect = () => ({ top: -100, bottom: 200 });
flux.querySelector('.text').dataset.h = '1000';
document.body.dispatchEvent(new window.Event('freshrss:load-more', { bubbles: true }));
assert.equal(flux.dataset.readMore, 'short');
assert.equal(flux.querySelectorAll('.read-more-btn').length, 0);
});