tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

text-autospace-edit-001.html (1228B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <link rel="help" href="https://drafts.csswg.org/css-text-4/#text-autospace-property">
      4 <link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
      5 <link rel="match" href="text-autospace-edit-001-ref.html">
      6 <style>
      7 #container {
      8  font-family: Ahem;
      9  font-size: 40px;
     10  text-autospace: normal;
     11 }
     12 </style>
     13 <div id="container">
     14  <div data-append="10">1国国国国国国国国国国</div>
     15  <div data-append="11">1国国国国国国国国国国国国</div>
     16 </div>
     17 <script>
     18 for (const reference of document.querySelectorAll("[data-append]")) {
     19  // Split the `textContent` at the `data-append` offset.
     20  const text = reference.textContent;
     21  const offset = parseInt(reference.dataset.append);
     22  const initiaL_text = text.substring(0, offset);
     23  const append_text = text.substring(offset);
     24 
     25  // Create a `<div>` with the `initial_text`, then append `append_text`
     26  // one character at a time, with a forced layout.
     27  const element = document.createElement("div");
     28  const text_node = document.createTextNode(initiaL_text);
     29  element.appendChild(text_node);
     30  reference.after(element);
     31  for (const ch of append_text) {
     32    element.offsetTop;
     33    text_node.appendData(ch);
     34  }
     35 }
     36 </script>