Skip to content

Commit

Permalink
fix(events): fix [emitChanges] not working with ES6-style Polymer ele…
Browse files Browse the repository at this point in the history
…ments
  • Loading branch information
hotforfeature committed May 15, 2017
1 parent 19fbc7d commit 009fdbd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/events/emit-changes.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export class EmitChangesDirective implements OnInit {
const klass = getCustomElementClass(this.elementRef);
if (klass) {
const properties = {};
this.copyKeysFrom((<any>klass).properties, properties);

// Hybrid element properties and behaviors
this.copyKeysFrom(klass.prototype.properties, properties);
if (klass.prototype.behaviors) {
klass.prototype.behaviors.map(behavior => {
Expand Down
4 changes: 4 additions & 0 deletions src/util/Polymer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export interface Polymer {
(info?: any): any;
CaseMap: Polymer.CaseMap;
Path: Polymer.Path;
Element: {
prototype: HTMLElement;
new(): HTMLElement;
};
}

declare global {
Expand Down
6 changes: 3 additions & 3 deletions src/util/getCustomElementClass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { getTagName } from './getTagName';

export function getCustomElementClass(elementRef: ElementRef): Function {
if (elementRef && elementRef.nativeElement) {
const htmlElement = Object.getPrototypeOf(elementRef.nativeElement);
if (htmlElement && htmlElement.is) {
return getCustomElements().get(htmlElement.is);
const klass = getCustomElements().get(elementRef.nativeElement.tagName.toLowerCase());
if (klass) {
return klass;
} else {
console.warn(`${getTagName(elementRef)} is not registered`);
}
Expand Down

0 comments on commit 009fdbd

Please sign in to comment.