Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The fragmentDirective read-only property of the Document interface returns the FragmentDirective for the current document.



Try running the following in a supporting browser's devtools, in a tab with one or more matched text fragments:


You should get a FragmentDirective object instance returned with a structure similar to the following:

items: [
  {prefix: '', textStart: 'Module Workers', textEnd: '', suffix: 'support', type: 'text'},
  {prefix: 'feedback on', textStart: 'usability', textEnd: '', suffix: '', type: 'text'}

This functionality is mainly intended for feature detection at present, but in future, it could be expanded to include other information such as translation hints.


Text Fragments
# dom-document-fragmentdirective

Browser compatibility

BCD tables only load in the browser

See also