commit | a15e439ed3e5080e1398ff1a8cfec6e904796a3c | [log] [tgz] |
---|---|---|
author | Thomas Steiner <steiner.thomas@gmail.com> | Fri Aug 07 15:52:05 2020 +0200 |
committer | GitHub <noreply@github.com> | Fri Aug 07 09:52:05 2020 -0400 |
tree | 257ab6cb61605fe8dbe787e1b984e791f352a312 | |
parent | 4c69eae033393dafe7791bb16511a8add837752b [diff] |
Reflect `fragmentDirective` location change (#10) * Reflect `fragmentDirective` location change * Reflect `fragmentDirective` location change * Reflect `fragmentDirective` location change
This is an attempt to polyfill the Text Fragments feature for browsers that don't support it directly.
There are still many limitations and the code is very hacky, but it serves well as a proof of concept. This could be used in Chrome for iOS by injecting the script with WKUserScript
.
From npm:
npm install text-fragments-polyfill
From unpkg:
<script type="module> if (!('fragmentDirective' in Location.prototype) && !('fragmentDirective' in document)) { import('https://unpkg.com/text-fragments-polyfill'); } </script>
// Only load the polyfill in browsers that need it. if (!('fragmentDirective' in Location.prototype) && !('fragmentDirective' in document)) { import('text-fragments.js'); }
Try the demo on a browser that does not support Text Fragments.
/src
.npm run start
and open http://localhost:8080/demo/ in a browser that does not support Text Fragments URLs directly, for example, Safari./demo/index.html
(look for location.hash
).Apache 2.0. This is not an official Google product.