/* eslint-env mocha, browser */ /* global proclaim */ it('is a function', function () { proclaim.isFunction(NodeList.prototype.forEach); });
componentDidMount() { // Add nodes that already exist at time React app is downloaded; const nodeList = document.querySelectorAll('.post_about_cat'); if (nodeList.length > 0) { this.setState({ nodeList }); } //Start watching for new specific nodes in outside app that contain class 'post_about_cat' const mutationObserver = new MutationObserver(mutations => { mutations.forEach(mutation => { const newNodes = mutation.addedNodes; newNodes.forEach(node => { if (node.classList && node.classList.contains('post_about_cat')) { this.setState(prevState => ({nodeList: [...prevState.nodeList, node]})); } }); }); }); mutationObserver.observe(document.body, { attributes: false, characterData: false, childList: true, subtree: true, attributeOldValue: false, characterDataOldValue: false }); }
it('has correct name', function () { proclaim.hasName(NodeList.prototype.forEach, 'forEach'); });
it('has correct arity', function () { proclaim.arity(NodeList.prototype.forEach, 1); });