This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/dan_abramov/status/794655915769266178 | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap | |
let ids = new weakMap() | |
let nextId = 1 | |
Object.defineProperty(Object.prototype, '__id__', { | |
get() { | |
if (!ids.has(this)) { | |
ids.set(this, nextId++) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/mxstbr/status/820228619549155328 | |
// https://babeljs.io/repl/#?babili=false&evaluate=false&lineWrap=false&presets=es2015&code=const%20someFunc%20%3D%20(something)%20%3D%3E%20%7B%0A%20%20switch%20(something)%20%7B%0A%20%20%20%20case%20'abc'%3A%0A%20%20%20%20%20%20const%20items%20%3D%20%5B'asdf'%5D%0A%20%20%20%20%20%20return%20items%0A%20%20%20%20case%20'xyz'%3A%0A%20%20%20%20%20%20const%20items%20%3D%20%5B'bla'%5D%0A%20%20%20%20%20%20%2F%2F%20%20%20%20%E2%86%91%0A%20%20%20%20%20%20%2F%2F%20%20%20%20Babel%20complains%20here%20about%20a%0A%20%20%20%20%20%20%2F%2F%20%20%20%20'Duplicate%20declaration%20%22items%22'%0A%20%20%20%20%20%20%2F%2F%20%20%20%20(see%20below)%0A%20%20%20%20%20%20%2F%2F%20%20%20%20Why%3F%3F%0A%20%20%20%20%20%20return%20items%0A%20%20%7D%0A%7D | |
const someFunc = (something) => { | |
switch (something) { | |
case 'abc': | |
const items = ['asdf'] | |
return items | |
case 'xyz': | |
const items = ['bla'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getBgColor(e, pseudo) { | |
var transparent = 'rgba(0, 0, 0, 0)' | |
if (!e) { | |
return transparent | |
} | |
var currentBgColor = window.getComputedStyle(e, pseudo).backgroundColor | |
if (currentBgColor === transparent) { | |
getBgColor(e.parentElement) |
OlderNewer