Skip to content

Instantly share code, notes, and snippets.

@idettman
Last active January 31, 2017 02:23
Show Gist options
  • Select an option

  • Save idettman/819e8239532624ab2bff864ceb8142a9 to your computer and use it in GitHub Desktop.

Select an option

Save idettman/819e8239532624ab2bff864ceb8142a9 to your computer and use it in GitHub Desktop.
event sandbox
setTimeout(function ()
{
let element = document.createElement('div');
element.textContent = 'subtree modification test';
document.body.appendChild(element);
console.log('setTimeout exit');
}, 1000);
function getOldAndNewHashValues(oldUrl, newUrl) {
let hashValues = {
old: '',
new: ''
};
/**
* @type {Number}
*/
let hashIndex = oldUrl.lastIndexOf('#');
if (hashIndex) {
let oldHash = oldUrl.substring(hashIndex + 1);
}
}
this.window.addEventListener('hashchange', event =>
{
console.log('hashchange: %O', event);
/**
* @type {String}
*/
let oldUrl = event.oldURL;
/**
* @type {String}
*/
let newUrl = event.newURL;
const hashValues = getOldAndNewHashValues(oldUrl, newUrl);
console.log('hash values: %O', hashValues);
let hashValue = window.location.hash.length > 3 ? '#' + window.location.hash.substring(1) : 'grey';
console.log('backgroundColor value: ', hashValue);
document.body.style.backgroundColor = hashValue;
});
document.addEventListener('DOMSubtreeModified', event => {
console.log('domsubtree modified: %O', event);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment