/* eslint-disable strict, no-var, vars-on-top, prefer-template */ 'use strict'; function appendSnackLink() { var usage = document.getElementById('usage'); if (usage) { var pre = usage.nextElementSibling; if ( pre && pre.firstChild.tagName === 'CODE' && pre.firstChild.className === 'language-js' ) { var link; var insert = true; if (pre.nextElementSibling && pre.nextElementSibling.dataset.snack) { link = pre.nextElementSibling; insert = false; } else { link = document.createElement('a'); link.dataset.snack = true; link.target = '_blank'; link.innerHTML = 'Try this example on Snack '; } var heading = document.querySelector('h1'); var href = 'https://snack.expo.io?name=' + encodeURIComponent( heading ? heading.textContent : document.title + ' Example' ) + '&description=' + encodeURIComponent(window.location.href) + '&code=' + encodeURIComponent(pre.textContent) + '&dependencies=react-native-paper'; if (link.href === href) { return; } link.href = href; if (insert) { pre.insertAdjacentElement('afterend', link); } } } } appendSnackLink(); var mutationObserver = new MutationObserver(mutations => { mutations.forEach(appendSnackLink); }); mutationObserver.observe(document.documentElement, { childList: true, subtree: true, });