on master help sign in
experimental support for setting favicons

Works in Chrome and FF for sure. Safari definitely does not work. Not sure about Opera and IE9+

commit665312543b09914c66eb859f0d262d9e1337a124 authorEvan Czaplicki <info@elm-lang.org> dateWed 15 Jan 2014, 12:59 (13 years ago) parentc602071
1 file changed+18
runtime/Init.js+18
runtime/Init.js+18
@@ -205,6 +205,24 @@ function addReceivers(ports) {
205205 if (v.length > 0) window.location = v;
206206 });
207207 }
208+ if ('favicon' in ports) {
209+ if (typeof ports.favicon === 'string') {
210+ changeFavicon(ports.favicon);
211+ } else {
212+ ports.favicon.subscribe(changeFavicon);
213+ }
214+ }
215+ function changeFavicon(src) {
216+ var link = document.createElement('link');
217+ var oldLink = document.getElementById('elm-favicon');
218+ link.id = 'elm-favicon';
219+ link.rel = 'shortcut icon';
220+ link.href = src;
221+ if (oldLink) {
222+ document.head.removeChild(oldLink);
223+ }
224+ document.head.appendChild(link);
225+ }
208226}
209227
210228function initGraphics(elm, Module) {