Skip to content

Instantly share code, notes, and snippets.

@sjmiles
sjmiles / database.js
Created April 6, 2012 04:53
OneCrayon's database.js updated for Enyo 2.0 compatibility
/*
---
script: database.js
description: Provides an interface to HTML 5 database objects for WebOS using an Enyo component
license: MIT license <http://www.opensource.org/licenses/mit-license.php>
authors:
ES6:
<element name="g-comp">
<template>
...
</template>
<script>
// 'elementElement' would have to expose this.template
var template = this.template;
class Comp {
constructor: function() {
@sjmiles
sjmiles / HtmlButton
Last active December 12, 2015 08:19
<!DOCTYPE html>
<html>
<head>
<title>Html Button</title>
<script src="../platform/platform.js"></script>
</head>
<body>
<element name="x-button" extends="button">
<template>
<style scoped>
@sjmiles
sjmiles / gist:5207722
Last active December 15, 2015 05:19
Basic example using Web Components/Custom Elements
<!DOCTYPE html>
<!--
Copyright 2013 The Toolkitchen Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<html>
<head>
<title></title>
<meta charset="UTF-8">
@sjmiles
sjmiles / messerly.html
Last active December 15, 2015 11:19
Particular Example Using MDV/ShadowDOM/CustomElements in Concert (Canary Only)
<!DOCTYPE html>
<!--
Copyright 2013 The Toolkitchen Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<html>
<head>
<title></title>
<meta charset="UTF-8">
@sjmiles
sjmiles / mdv-createInstance.html
Last active December 15, 2015 12:09
Exploring expectations around template.createInstance
<!DOCTYPE html>
<!--
Copyright 2013 The Toolkitchen Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
<html>
<head>
<title></title>
<meta charset="UTF-8">
bind: function(inName, inModel, inPath) {
if (inModel.isToolkitElement) {
Toolkit.bindProperties(this, inName, inModel, inPath);
} else {
HTMLElement.prototype.bind.apply(this, arguments);
}
}

Case 1: intrinsic ShadowDOM

// markup
<x-foo>My Content</x-foo>

// innerHTML should only ever reflect light dom, node contents 
// are interchangeable without regard to the node itself
xfoo.innerHTML === ‘My Content’

// outerHTML does not reflect ShadowDOM, as (if it exists) it’s

@sjmiles
sjmiles / gist:5515511
Last active December 16, 2015 23:39
Toolkit dependency 'early warning' system
<!-- bad thing to be avoided -->
<element name="x-foo">
<script>
rarelyUsedMethod: function() {
missingDependency.doWork();
}
</script>
</element>
<element name="google-plusone">
<script>
Polymer.register(this, {
ready: function() {
addInstance(this);
},
plusOneReady: function() {
// do stuff
}
});