mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-23 11:42:21 +00:00
Street Level photo viewer: keyless ranking, closed waits, a moved canvas
Review follow-ups to the previous commit: - photoViewers.js ranks a presentation without a mountKey as mounted when it began presenting (after the latest key seen, before any later mount), so a photo viewer mounting while a keyless one shows is drawn and the keyless one superseded; supersede is queued whenever more than one presents after any change, not only when the pick changes. - A panorama's open still waiting on a draw when the last view leaves fails as closed and leaves no photo shown, instead of uploading to a canvas never drawn. A mount waiting on its first draw then also fails as closed and is unmounted, so a view subscribing later sees nothing. - A view handing back another canvas element than the renderer's drops the renderer and draws the panorama again on the new one, as after a lost context. - The guard test allows a .src write in loadImage only on the one `image` binding, created by new Image() and never rebound or shadowed, and refuses `(expr).src =` and bracket property writes anywhere. - The test fakes' shared view is reset before each test (resetPhotoView), so a viewer left by an earlier test is neither drawn with nor superseded by a later test's. Nothing changes in the running app. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
33ac0545ef
commit
e6f21777ba
11 files changed
+327
-50
No files matched your search
@@ -101,11 +101,38 @@ test('the photo viewer is drawn by its view, and its layer needs no Vue', () =>
|
||||
/from 'vue'|\.vue'/,
|
||||
])
|
||||
assert.doesNotMatch(source, write);
|
||||
assert.doesNotMatch(rest, /\.src\s*=[^=]/, 'a .src written on the page');
|
||||
// In loadImage, only on the off-page Image it creates.
|
||||
// No property written through brackets (`picture['src'] = …`,
|
||||
// `el[name] = …`), outside array destructuring declarations.
|
||||
assert.doesNotMatch(
|
||||
source.replace(/\b(?:const|let|var)\s*\[/g, ''),
|
||||
/[\w$)\]]\s*\[[^[\]]*\]\s*=(?![=>])/,
|
||||
'a bracket write',
|
||||
);
|
||||
const SRC = /\.src\s*=(?![=>])/g;
|
||||
assert.doesNotMatch(rest, SRC, 'a .src written on the page');
|
||||
// In loadImage, only on the off-page Image it creates: `image` is bound
|
||||
// once, to that Image, and never rebound or shadowed.
|
||||
assert.match(loader, /\bconst image = new Image\(\);/);
|
||||
for (const [write] of loader.matchAll(/[\w$.\]]+\.src\s*=(?!=)/g))
|
||||
assert.match(write, /^image\.src\s*=$/, write);
|
||||
assert.equal(
|
||||
loader.match(/\b(?:const|let|var|function|class)\s+image\b/g)?.length,
|
||||
1,
|
||||
'one binding of image',
|
||||
);
|
||||
for (const rebinding of [
|
||||
/(?<!\b(?:const|let|var)\s+)(?<![\w$.])image\s*=(?![=>])/,
|
||||
/(?<![\w$.])image\s*=>/,
|
||||
/\((?:[^()]*[,{[\s(])?image\b[^()]*\)\s*=>/,
|
||||
/\bfunction\b[^(]*\((?:[^)]*[,{[\s(])?image\b[^)]*\)/,
|
||||
/\b(?:const|let|var)\s*[{[][^=]*\bimage\b/,
|
||||
/\bcatch\s*\(\s*image\b/,
|
||||
])
|
||||
assert.doesNotMatch(loader, rebinding, 'image rebound or shadowed');
|
||||
const writes = loader.match(SRC)?.length ?? 0;
|
||||
assert.equal(
|
||||
loader.match(/(?<![\w$.)\]])image\.src\s*=(?![=>])/g)?.length ?? 0,
|
||||
writes,
|
||||
'a .src written on something other than the Image',
|
||||
);
|
||||
const markup = template(VIEW);
|
||||
const opening = (name, attribute) =>
|
||||
new RegExp(String.raw`<${name}\b${ATTRS}\s${attribute}${ATTRS}>`);
|
||||
|
||||
Reference in new issue
Block a user