Skip to content

Commit 5ac0983

Browse files
committed
support text
1 parent 0a01654 commit 5ac0983

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@node-projects/svghmi.webcomponent",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "a svghmi webcomponent.",
55
"type": "module",
66
"main": "./dist/index.js",

src/Converter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class Converter {
6666
}
6767

6868
static Alpha(col: string) {
69-
return col.substring(2,2);
69+
return col.substring(2, 4);
7070
}
7171

7272
static Iluminate(input: string, deviation: number, low = '#FFFFFF', high = '#000000') {

src/SvgHmi.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class SvgHmi extends BaseCustomWebComponentConstructorAppend {
2020

2121
public _svgHmiProperties: Map<string, { name: string, type: string, default: string }> = new Map();
2222
public _svgHmiLocalDefs: Map<string, { name: string, type: string, value: string }> = new Map();
23-
private _boundAttributes: { element: Element, attribute: string, value: string }[] = [];
23+
private _boundAttributes: { element: Element, elementParent?: Element, attribute: string, value: string }[] = [];
2424

2525
#src: string;
2626
set src(value: string) {
@@ -148,6 +148,11 @@ export class SvgHmi extends BaseCustomWebComponentConstructorAppend {
148148
for (let b of this._boundAttributes) {
149149
if (b.element.localName == "localDef") {
150150
this._svgHmiLocalDefs.get(b.element.getAttribute('name')).value = evalWithContext(this, b.value);
151+
} else if (b.element.localName == "text" && b.element.namespaceURI == "http://svg.siemens.com/hmi/") {
152+
const par = b.elementParent ?? b.element.parentNode;
153+
b.elementParent = <Element>par;
154+
par.textContent = evalWithContext(this, b.value);
155+
//this._svgHmiLocalDefs.get(b.element.getAttribute('name')).value = evalWithContext(this, b.value);
151156
} else {
152157
const val = evalWithContext(this, b.value);
153158
b.element.setAttribute(b.attribute, val);

0 commit comments

Comments
 (0)