Origami Frontend Components & Services

Readme: o-dom

o-dom is deprecated. This component should not be used for new projects. Only security-related bugs will be fixed for this component, though existing implementations will continue to work.

Origami DOM manipulation & traversal helpers.




Get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.



< DOMElement > or false


var dom = require('o-dom');
var closestListItem = dom.getClosestMatch(document.querySelector('li a'), 'li');


Get the index of an element.



< Number >

Example, assuming this HTML structure:

    <li id="target"></li>

dom.getIndex(document.getElementById('target')); would return 1.


This module is suitable for helper functions that provide a convenient means of performing commonly required generic manipulation or selection of DOM elements. It should not be extended to contain:


If you have any questions or comments about this component, or need help using it, please either raise an issue, visit #ft-origami or email Origami Support.


This software is published by the Financial Times under the MIT licence.

Switch component view

GitHub Repository

Install o-dom

If using the Build Service, add o-dom@^2.0.10 to your script tag.

If running a Manual Build, run bower install --save "o-dom@^2.0.10".

Help & Support

o-dom is maintained directly by the Origami team. If you have any questions about o-dom or Origami in general, we are happy to help. 😊

Slack: #ft-origami
Email: origami.support@ft.com

Feedback / Issues

To report a bug or request features please create an issue on Github. For support or general feedback please get in touch 😊

Slack: #ft-origami
Email: origami.support@ft.com