Skip to content

Commit

Permalink
Ensure label component is updated when its text content is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
claudijo committed Mar 29, 2022
1 parent eff3667 commit bacfe3c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
10 changes: 9 additions & 1 deletion dist/index.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,14 @@ var CanvasLabel = /*#__PURE__*/function (_AbstractShape) {
}

_createClass(CanvasLabel, [{
key: "textContent",
get: function get() {
return this.getTextualAttribute('textContent', '');
},
set: function set(value) {
this.setAttribute('textContent', value);
}
}, {
key: "fontSize",
get: function get() {
return this.getNumericAttribute('fontSize', 10);
Expand Down Expand Up @@ -2006,7 +2014,7 @@ var CanvasLabel = /*#__PURE__*/function (_AbstractShape) {
}], [{
key: "observedAttributes",
get: function get() {
return [].concat(_toConsumableArray(AbstractShape.observedAttributes), ['color', 'fontsize', 'fontfamily', 'fontstyle', 'fontweight', 'baseline', 'align', 'maxwidth']);
return [].concat(_toConsumableArray(AbstractShape.observedAttributes), ['color', 'fontsize', 'fontfamily', 'fontstyle', 'fontweight', 'baseline', 'align', 'maxwidth', 'textcontent']);
}
}]);

Expand Down
10 changes: 9 additions & 1 deletion dist/index.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1832,6 +1832,14 @@ var CanvasLabel = /*#__PURE__*/function (_AbstractShape) {
}

_createClass(CanvasLabel, [{
key: "textContent",
get: function get() {
return this.getTextualAttribute('textContent', '');
},
set: function set(value) {
this.setAttribute('textContent', value);
}
}, {
key: "fontSize",
get: function get() {
return this.getNumericAttribute('fontSize', 10);
Expand Down Expand Up @@ -1998,7 +2006,7 @@ var CanvasLabel = /*#__PURE__*/function (_AbstractShape) {
}], [{
key: "observedAttributes",
get: function get() {
return [].concat(_toConsumableArray(AbstractShape.observedAttributes), ['color', 'fontsize', 'fontfamily', 'fontstyle', 'fontweight', 'baseline', 'align', 'maxwidth']);
return [].concat(_toConsumableArray(AbstractShape.observedAttributes), ['color', 'fontsize', 'fontfamily', 'fontstyle', 'fontweight', 'baseline', 'align', 'maxwidth', 'textcontent']);
}
}]);

Expand Down
9 changes: 9 additions & 0 deletions lib/shapes/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,18 @@ export class CanvasLabel extends AbstractShape {
'baseline',
'align',
'maxwidth',
'textcontent',
];
}

get textContent() {
return this.getTextualAttribute('textContent', '');
}

set textContent(value) {
this.setAttribute('textContent', value);
}

get fontSize() {
return this.getNumericAttribute('fontSize', 10);
}
Expand Down

0 comments on commit bacfe3c

Please sign in to comment.