[object Object]

← back to Dw Domain Fleet

fix(catalog): guard requestSubmit — Safari <16 would have re-killed the sort (TK-11470)

95a4e5a62303fa0c3ff501412faa02378764900a · 2026-09-11 12:55:47 -0700 · Steve Abrams

Red-team catch on the previous commit. HTMLFormElement.prototype.requestSubmit is
Safari 16+ (Sept 2022). On older WebKit the property is undefined, so .call() throws
inside the change listener and the dropdown goes dead again — the exact bug b4b8158
fixes, with a new cause, on precisely the browsers our Playwright engines are too new
to catch.

Feature-detects and falls back to submit(), still invoked off the prototype so a field
named submit/requestSubmit can't clobber it.

Proven by simulating an old browser: with requestSubmit deleted from the prototype,
sorting still navigates and re-orders correctly in both engines, 0 pageerrors. Same
harness scores 0/38 on the unfixed baseline and 38/38 here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AyGLosyy49Y6TsyiwWQWnx

Files touched

Diff

commit 95a4e5a62303fa0c3ff501412faa02378764900a
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Fri Sep 11 12:55:47 2026 -0700

    fix(catalog): guard requestSubmit — Safari <16 would have re-killed the sort (TK-11470)
    
    Red-team catch on the previous commit. HTMLFormElement.prototype.requestSubmit is
    Safari 16+ (Sept 2022). On older WebKit the property is undefined, so .call() throws
    inside the change listener and the dropdown goes dead again — the exact bug b4b8158
    fixes, with a new cause, on precisely the browsers our Playwright engines are too new
    to catch.
    
    Feature-detects and falls back to submit(), still invoked off the prototype so a field
    named submit/requestSubmit can't clobber it.
    
    Proven by simulating an old browser: with requestSubmit deleted from the prototype,
    sorting still navigates and re-orders correctly in both engines, 0 pageerrors. Same
    harness scores 0/38 on the unfixed baseline and 38/38 here.
    
    Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_01AyGLosyy49Y6TsyiwWQWnx
---
 shared/render.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/shared/render.js b/shared/render.js
index b792192..70ecccc 100644
--- a/shared/render.js
+++ b/shared/render.js
@@ -781,7 +781,16 @@ ${script(cfg)}
     var input=document.createElement('input');input.type='hidden';
     input.name=key;input.value=value;Node.prototype.appendChild.call(form,input);
   });
-  ss.addEventListener('change',function(){save(sk,ss.value);HTMLFormElement.prototype.requestSubmit.call(form);});
+  // requestSubmit() is Safari 16+ (Sep 2022); on older WebKit the property is undefined and
+  // .call() would throw inside this listener, silently killing the dropdown again — the very
+  // bug this block exists to fix, just with a new cause. Fall back to submit(), still called
+  // off the prototype so a field named "submit"/"requestSubmit" can't clobber it.
+  function send(){
+    var F=HTMLFormElement.prototype;
+    try{ if(typeof F.requestSubmit==='function'){F.requestSubmit.call(form);return;} }catch(e){}
+    F.submit.call(form);
+  }
+  ss.addEventListener('change',function(){save(sk,ss.value);send();});
   var saved=read(sk);
   var valid=Array.prototype.some.call(ss.options,function(o){return o.value===saved;});
   if(!params.has('sort') && valid && saved!==ss.value){

← b4b8158 fix(catalog): sort dropdown was dead on all 8 funnel sites —  ·  back to Dw Domain Fleet  ·  catalog sort: stop remembering the sort, so Back works and t d0f8c70 →