Skip to content

Commit

Permalink
fix(attribute): fix support for dashed bindables
Browse files Browse the repository at this point in the history
bindables from custom elements are now properly supported
with attribute-based translations

fixes issue #168 and
#169
  • Loading branch information
zewa666 committed Oct 24, 2016
1 parent bc79975 commit e70372c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class I18N {
while (i--) {
let key = keys[i];
// remove the optional attribute
let re = /\[([a-z\-]*)\]/g;
let re = /\[([a-z\-]*)\]/ig;

let m;
let attr = 'text';
Expand All @@ -181,6 +181,9 @@ export class I18N {
if (!node._textContent) node._textContent = node.textContent;
if (!node._innerHTML) node._innerHTML = node.innerHTML;

// convert to camelCase
attr = attr.replace(/-([a-z])/g, function(g) { return g[1].toUpperCase(); });

//handle various attributes
//anything other than text,prepend,append or html will be added as an attribute on the element.
switch (attr) {
Expand Down Expand Up @@ -232,6 +235,7 @@ export class I18N {
node.innerHTML = this.tr(key, params);
break;
default: //normal html attribute
debugger;
if (node.au &&
node.au.controller &&
node.au.controller.viewModel &&
Expand Down

0 comments on commit e70372c

Please sign in to comment.