Skip to content

Instantly share code, notes, and snippets.

View TakayoshiKochi's full-sized avatar

Takayoshi Kochi TakayoshiKochi

View GitHub Profile
@TakayoshiKochi
TakayoshiKochi / query-slotted.js
Created August 9, 2017 07:22
Replacement for querySelector("::slotted(x)")
function querySlotted(root, selector) {
let slots = root.querySelectorAll('slot');
let matched = [];
slots.forEach((slot) => {
matched = matched.concat(slot.assignedNodes().filter((el) => {
return el.matches(selector);
}));
});
return matched;
}
@TakayoshiKochi
TakayoshiKochi / html-modules-issue645.md
Last active March 27, 2019 04:45
Summary of HTML Modules discussion

HTML Modules summary (issue#645)

Initial: Jun. 28, 2017 / Last Update: Aug. 14, 2017

What is this?

This is the summary of the discussion happening for HTML Modules at webcoomponents#645.

There appear to be lots of diverse opinions, and I'll try to capture them, summarize and provide here for catching up with the discussion for all. Note that this document should never be considered official, complete or final. If anything is wrong or lost, please let @TakayoshiKochi know.

@TakayoshiKochi
TakayoshiKochi / shadow-v1-style-sharing.html
Created January 11, 2017 08:09
Style Sharing for Shadow DOM v1
<!doctype html>
<html>
<body>
</body>
<script>
'use strict';
let host = document.createElement('div');
const numChildren = 10000;
for (var i = 0; i < numChildren; ++i) {
@TakayoshiKochi
TakayoshiKochi / deep-combinator-benchmark2.html
Created December 2, 2016 08:22
Benchmark for '>>>' and polyfill comparison (2)
<!DOCTYPE html>
<body>
<div id="root"></div>
</body>
<script>
'use strict';
if (window.testRunner) {
testRunner.dumpAsText();
}
@TakayoshiKochi
TakayoshiKochi / querySelector-benchmark.html
Created December 2, 2016 08:11
Benchmark for selectors with/without '>>>'
<!DOCTYPE html>
<body>
<div id="root"></div>
</body>
<script>
'use strict';
if (window.testRunner) {
testRunner.dumpAsText();
}
@TakayoshiKochi
TakayoshiKochi / deep-combinator-benchmark.html
Created December 2, 2016 07:36
Benchmark for '>>>' and polyfill comparison.
<!DOCTYPE html>
<body>
<div id="root"></div>
</body>
<script>
'use strict';
if (window.testRunner) {
testRunner.dumpAsText();
}
@TakayoshiKochi
TakayoshiKochi / Custom-Elements-in-Imports.md
Last active September 3, 2019 13:58
CEv1 in classic HTML Imports

Custom Elements V1 in HTML Imports

This document describes how custom elements v1 work when they are defined or used in HTML Imports.

HTML Imports is currently implemented only in Chrome, and this document provides non-normative information about Chrome's implementation in M54 and later, for the reference of future works that tries to achieve similar functionality like HTML Imports.

Defining Custom Element in an imported document

As the global context window is shared with script running in an imported document, you can access the custom elements registry via window.customElements. This is straightforward and no different from the usage in a usual HTML document.

@TakayoshiKochi
TakayoshiKochi / focus.md
Last active June 7, 2021 14:52
document.documentElement.focus()

http://crbug.com/467043

IE11:
  (default)
  document.body.tabIndex = 0
  document.head.tabIndex = 0
  document.documentElement.tabIndex = 0
  
 document.body.focus() -&gt; work (regardless of tabIndex)
@TakayoshiKochi
TakayoshiKochi / functional.cc
Last active August 29, 2015 14:05
Practice C++ functor??
#include <iostream>
int add1(int x) {
return ++x;
}
int double2(int x) {
return 2 * x;
}