Skip to content

bugfix: duplicate content naked forms #412

Matthieu Fesselier requested to merge bugfix/412-duplicate-content into master

@sylvain @clement What do you think of this fix? It's ugly but it works.
Here is a test case:

<!DOCTYPE html>
    <html>
    <head>
      <title>Camionnet.fr</title>
      <script type="module" src="/src/index.js"></script>
      <script type="module" src="https://unpkg.com/@startinblox/router@0.7"></script>
    </head>
    
    <body>
      <sib-router id="main-router" default-route="clients">
        <sib-route name="nouvelle-prestation"></sib-route>
      </sib-router>
    
      <div id="nouvelle-prestation" hidden>
          <div>
            <sib-form
            id="add-service-sib-form"
            data-src="https://camionnet.happy-dev.fr/api/services/1/"
            data-fields="immatriculation"
            naked
            ></sib-form>
          </div>
        </div>
    
        <script>
          document.querySelector("#main-router").addEventListener("navigate", (e) => {
              const addServiceSibForm = document.querySelector("#add-service-sib-form");
              addServiceSibForm.dataset.src = addServiceSibForm.dataset.src;
          });
        </script>
    </body>
</html>

And then call http://localhost:3000/nouvelle-prestation.
If you have a 404, you may need to modify a bit your node server:

...
(async ()=>{
  const server = app
    .use(express.static(distPath))
    .get(/^[^.]*$/, (req, rep) =>
      rep.sendFile(join(__dirname, distPath, '/index.html')),
    )
    .listen((await port)[0])
    ;
  console.log(address(server.address()));
})();
... 

Merge request reports