Origami Frontend Components & Services

Readme: o-dom active

Origami DOM manipulation & traversal helpers.

Usage

JavaScript

getClosestMatch

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

Arguments

Returns

< DOMElement > or false

Example:

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

getIndex

Get the index of an element.

Arguments

Returns

< Number >

Example, assuming this HTML structure:

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

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

Contributing

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:


Contact

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.


Licence

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.6 to your script tag.

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

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