class B {
constructor(x) {
this.x = x;
}
static [Symbol.create]() {
var o = super();
weakMap.set(o, 123456789); // Dom wrapper foo
return o;
}
This file contains 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
<link rel="import" href="../core-scaffold/core-scaffold.html"> | |
<link rel="import" href="../core-header-panel/core-header-panel.html"> | |
<link rel="import" href="../core-menu/core-menu.html"> | |
<link rel="import" href="../core-item/core-item.html"> | |
<link rel="import" href="../core-icon-button/core-icon-button.html"> | |
<link rel="import" href="../core-toolbar/core-toolbar.html"> | |
<link rel="import" href="../core-menu/core-submenu.html"> | |
<link rel="import" href="../google-map/google-map.html"> | |
<polymer-element name="my-element"> |
This file contains 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
if (!Document.prototype.createAttributeNS) { | |
Document.prototype.createAttributeNS = function(namespaceURI, qualifiedName) { | |
var dummy = this.createElement('dummy'); | |
dummy.setAttributeNS(namespaceURI, qualifiedName, ''); | |
var attr = dummy.attributes[0]; | |
dummy.removeAttributeNode(attr); | |
return attr; | |
}; | |
} |
This file contains 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() { | |
'use strict'; | |
function uncurryThis(f) { | |
return f.call.bind(f); | |
} | |
var ShadowRoot = window.ShadowRoot; | |
var createShadowRoot = uncurryThis(Element.prototype.createShadowRoot); | |
var ownerDocumentGetter = uncurryThis(Object.getOwnPropertyDescriptor(Node.prototype, 'ownerDocument').get); |
When called, the register method must run these steps:
ENVIRONMENT
, the unit of related similar-origin browsing contextsDOCUMENT
, the context object of the methodNAME
, the custom element name of the element being registeredFUNCTION
, the custom element constructor function, optional
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="../polymer/polymer.js"></script> | |
</head> | |
<body> | |
<template id="host-template"> | |
<div>host shadowRoot</div> | |
<content></content> | |
</template> |
This file contains 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
// XXX should be standard (and named clone, after Java?) | |
Object.prototype.copy = function () { | |
let o = {} | |
for (let i in this) | |
o[i] = this[i] | |
return o | |
} | |
// Containment testing for arrays and strings that should be coherent with their iterator. | |
Array.prototype.contains = String.prototype.contains = function (e) { |
This file contains 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
traceur --out out.js parser.js | |
# Traceur does not strip dead code. Use Uglify2. | |
uglifyjs src/runtime/runtime.js out.js -cm -o out.min.js |
This file contains 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
// Create is defined in the latest ES6 spec. Foo[create]() is used to create the instance | |
// when you do "new Foo". This instance is then passed to Foo.call(instance, <args>) | |
import {create} from '@reflect'; | |
Element[create] = function() { | |
return documemt.createElementNS(this.prototype.namespaceURI, this.prototype.localName) | |
}; |
This file contains 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
Object.prototype.$super = function() { | |
var func = arguments.callee.caller; | |
var name = func.foundName_; | |
if (!name) { | |
for (var p in this) { | |
if (this[p] == func) { | |
name = p; | |
break; | |
} | |
} |