Permalink
Browse files

feat(default context): The templiteral function now sets context to t…

…his by default
  • Loading branch information...
calebdwilliams committed Nov 3, 2017
1 parent 597ba56 commit 796f7847457e529ff692a16d5a02000da1a05e93
Showing with 5 additions and 5 deletions.
  1. +1 −1 src/templiteral.js
  2. +2 −1 static/scripts/module.js
  3. +2 −3 static/templiteral.js
@@ -19,7 +19,7 @@ function html(location) {
};
}

export function templiteral(location, context) {
export function templiteral(location, context = this) {
function render(...args) {
const renderer = Reflect.apply(html, context, [location]);
return Reflect.apply(renderer, context, args);
@@ -15,6 +15,7 @@ class MyEl extends HTMLElement {

constructor() {
super();
this.templiteral = templiteral;
this._shadowRoot = this.attachShadow({ mode: 'open' });
this.pContentEditable = false;
}
@@ -71,7 +72,7 @@ class MyEl extends HTMLElement {
}

render() {
templiteral(this._shadowRoot, this)`
this.templiteral(this._shadowRoot)`
<style>
.everyone {
color: tomato;
@@ -59,7 +59,6 @@ class AttributeNode {
const newAttr = newNode.boundAttrs.get(attr.name);
newAttr && attr.value !== newAttr.value ? attr.value = newAttr.value : null;

/* TODO */
if (attr.name.match(propPattern)) {
this.updateAttributes(attr.name, newAttr);
}
@@ -180,10 +179,10 @@ function html(location) {
compiler = new Template(output, location, this);
templateCache.set(templateKey, compiler);
}
}
};
}

function templiteral(location, context) {
function templiteral(location, context = this) {
function render(...args) {
const renderer = Reflect.apply(html, context, [location]);
return Reflect.apply(renderer, context, args);

0 comments on commit 796f784

Please sign in to comment.