Skip to content

Instantly share code, notes, and snippets.

View setDeep.js
/**
* Helpers for Flarum
*
* Allows you to do the following
* setDeep(vdom, 'attrs.style.borderColor', '#f00')
* mergeDeep(this.props, {className: 'Class', params: {q: null}})
*/
// https://stackoverflow.com/questions/27936772/how-to-deep-merge-instead-of-shallow-merge
/**
@nxta
nxta / vdom.js
Created Jan 8, 2020
Helper function for Flarum to traverse a Mithril Virtual DOM using basic CSS selector syntax
View vdom.js
/**
* // Desired usage:
* import vdom from 'flarum/helpers/vdom';
* import {find, vdom} from 'flarum/helpers/vdom';
*
* // Supports tagname, class and id selectors
* vdom('.container ul#logo li.item.item-one a') // Returns array of vnodes
* find('.username') // Returns array of objects containing the vnode and more information {vnode, parent, index}
*
* // Example: