Skip to content

Instantly share code, notes, and snippets.

@cdata
cdata / css.pegjs
Last active August 31, 2018 00:25
{
function value(value, unit) {
return {
type: 'value',
value,
unit
};
}
function splitArgs(args) {
<script type="module">
import {MyElement} from './my-element.html#definition';
document.body.appendChild(new MyElement());
</script>
<template>
<!-- A host directive applies associated part changes to the host element, if any -->
<template directive="host" class="{{foo}} bar" prop$="{{value}}"></template>
</template>
const Fooable: DomainExtender<Foo, {}> = ({ Alpha, Beta }) => {
const a = new Alpha();
const AlphaWithFoo = class extends Alpha {
constructor(...args: any[]) {
super(...args);
}
foo: string = 'foo';
};
return { Alpha: AlphaWithFoo, Beta };
<template>
<!-- This element does not expect to be used in a template instance, but
does require that it be furnished with a template child in order to
render internally -->
<third-party-infinite-list-element>
<template>
<some-list-item>
</template>
</third-part-infinite-list-element>
</template>
@cdata
cdata / test.html
Last active February 22, 2018 20:08
<needle-element name="x-foo">
<template>
<!-- A host directive applies associated part changes to the host element, if any -->
<template directive="host" class="{{foo}} bar" prop$="{{value}}"></template>
<!-- A compute directive computes a value from several inputs and assigns the result to a property key -->
<template directive="compute" expression="{{computeState(foo, bar, baz)}}" result="state"></template>
<ul>
<!-- A foreach directive renders a list of items -->
// /foo/1.0/namemap.json
{
"packages": {
"bar": "../../bar/1.0",
"baz": "../../baz/1.0"
}
}
// /bar/1.0/namemap.json
{
const applyMixins = (BaseClass, ...mixins) => {
let Implementation = BaseClass;
for (mixin of mixins) {
Implementation = mixin(Implementation);
}
return Implementation;
}
// Later...
const alphaMixin = SuperClass => class extends SuperClass {
export function FixturedTest(TestImplementation) {
return class extends TestImplementation {
async wind(context) {
const testContext = await super.wind(context);
const { implementation } = testContext;
const { topic } = this;
const fixtureContext = topic != null ? topic.createContext() : {};
return Object.assign({}, testContext, { fixtureContext, implementation: (...args) => implementation(...args, fixtureContext) });
}
async unwind(context) {
@cdata
cdata / manifest.json
Created January 8, 2018 05:33
More MediaBox
{
"manifest_version": 2,
"name": "MoreMediaBox",
"version": "1.0",
"content_scripts": [{
"matches": ["*://*.mymediabox.com/*"],
"all_frames": true,
"css": ["./more-media-box.css"]
}]
}