(activeHref, activeTitle)
| 82 | var sessionStorageKey = 'activeStylesheetHref'; |
| 83 | |
| 84 | function handleSwitch(activeHref, activeTitle) { |
| 85 | var activeElm = document.querySelector('link[href*="' + activeHref + '"],link[title="' + activeTitle + '"]'); |
| 86 | |
| 87 | if (!activeElm && activeHref) { |
| 88 | activeElm = document.createElement('link'); |
| 89 | activeElm.setAttribute('href', activeHref); |
| 90 | activeElm.setAttribute('rel', 'stylesheet'); |
| 91 | activeElm.setAttribute('title', activeTitle); |
| 92 | |
| 93 | document.head.appendChild(activeElm); |
| 94 | |
| 95 | activeElm.addEventListener('load', function linkOnLoad() { |
| 96 | activeElm.removeEventListener('load', linkOnLoad); |
| 97 | setActiveLink(activeElm); |
| 98 | }); |
| 99 | } |
| 100 | else if (activeElm) { |
| 101 | setActiveLink(activeElm); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | function setActiveLink(activeElm) { |
| 106 | var activeHref = activeElm.getAttribute('href'); |
no test coverage detected