commit | 5593fc403e4d1ee06a68ff710932d59c06a87df9 | [log] [tgz] |
---|---|---|
author | Tommy Martino <31107939+tfmar@users.noreply.github.com> | Mon Aug 10 16:17:07 2020 -0400 |
committer | GitHub <noreply@github.com> | Mon Aug 10 16:17:07 2020 -0400 |
tree | df9b9aefba42c215110157c6e424b508c6e94243 | |
parent | 7c34ed457b282b3a3dec4dc9ea8aed63ad757825 [diff] |
Adding basic structure for spec-conforming implementation (#12)
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.