Skip to content

Instantly share code, notes, and snippets.

View esprehn's full-sized avatar

Elliott Sprehn esprehn

View GitHub Profile
<!doctype html>
<script>
function a() {
return new Promise((resolve, reject) => {
setTimeout(() => reject(new Error('test')), 100);
});
}
function b() {
return new Promise((resolve, reject) => {
setTimeout(() => resolve(), 100);
@esprehn
esprehn / text.js
Created August 30, 2017 01:55
spreading the woes
[...null]
// VM2014:1 Uncaught TypeError: Cannot read property 'Symbol(Symbol.iterator)' of null
// at <anonymous>:1:5
[...undefined]
// VM2026:1 Uncaught TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined
// at <anonymous>:1:5
{...undefined}
// {}
@esprehn
esprehn / caret.html
Created March 23, 2017 23:32
Blinking caret that sleeps the main thread for 500ms
<!DOCTYPE html>
<style>
#caret {
height: 16px;
width: 1px;
background: black;
will-change: opacity;
opacity: 1;
transition: opacity;
../../third_party/WebKit/Source/wtf/text/StringConcatenate.h:272:42: error: no matching constructor for initialization of 'StringTypeAdapter<const char *const>'
StringTypeAdapter<const StringType1> adapter1(string1);
^ ~~~~~~~
../../third_party/WebKit/Source/wtf/text/StringOperators.h:40:23: note: in instantiation of function template specialization 'WTF::makeString<const char *, WTF::String>' requested here
return String(makeString(m_string1, m_string2));
^
../../third_party/WebKit/Source/core/clipboard/DataTransferItemList.cpp:82:61: note: in instantiation of member function 'WTF::StringAppend<const char *, const WTF::String>::operator String' requested here
exceptionState.throwDOMException(NotSupportedError, "An item already exists for type '" + type + "'.");
^
../../third_party/WebKit/Source/wtf/text/StringConcatenate.h:47:7: note: candidate constructor (the
@esprehn
esprehn / pseudos.js
Last active September 1, 2016 04:18
Find all the pseudos
(function() {
var selectors = new Map();
for (let sheet of Array.from(document.styleSheets)) {
for (let rule of Array.from(sheet.cssRules || [])) {
var text = rule.selectorText || "";
for (let match of (text.match(/\:([a-zA-Z0-9\-]+)/g) || []))
selectors.set(match, (selectors.get(match) || 0) + 1);
}
}
return [
Clockwise from the podium:
Peter Linss
Rossen (Microsoft)
tabatkins@
esprehn@
Brad Kemper
kojii@
Andre Ribkey
Elika (fantasai)
<!DOCTYPE html>
<body>
<template id="template">
<style>
:host { color: red; display: block; }
</style>
<div>Example</div>
</template>
<!DOCTYPE html>
<body>
<template id="template">
<style>
:host { color: red; display: block; }
</style>
<div>Example</div>
</template>
DocumentStyleSheetCollection::updateActiveStyleSheets mode=0 type=0 full=1
#0 0x7fc54872a153 base::debug::StackTrace::StackTrace()
#1 0x7fc53e16eb10 blink::DocumentStyleSheetCollection::updateActiveStyleSheets()
#2 0x7fc53e1c4b09 blink::StyleEngine::updateActiveStyleSheets()
#3 0x7fc53e080d8d blink::Page::settingsChanged()
#4 0x7fc5476af266 blink::WebSettingsImpl::setStandardFontFamily()
#5 0x7fc5464f3cd7 content::RenderView::ApplyWebPreferences()
#6 0x7fc5464f2458 content::RenderViewImpl::Initialize()
#7 0x7fc5464f4917 content::RenderViewImpl::Create()
@esprehn
esprehn / Sheet API.idl
Created February 18, 2016 01:50
CSSStyleSheet API
dictionary CSSStyleSheetInit {
// TODO: Should also take a MediaList, but those have no constructor. When
// it does take those, it should make a copy so mutations to the list don't
// impact the sheet. This is for v2 of the API.
DOMString media = "";
DOMString title = "";
boolean alternate = false;
boolean disabled = false;
};