Files
docx-js/ts/docx/xml-components/default-attributes.ts

30 lines
767 B
TypeScript
Raw Normal View History

import {BaseXmlComponent} from "./base";
2016-05-23 22:23:05 +01:00
import * as _ from "lodash";
export abstract class XmlAttributeComponent extends BaseXmlComponent {
protected root: Object;
private xmlKeys: Object;
constructor(xmlKeys: Object, properties: Object) {
super("_attr");
this.xmlKeys = xmlKeys;
this.root = properties
if (!properties) {
this.root = {};
}
}
replaceKey(): void {
if (this.root !== undefined) {
_.forOwn(this.root, (value, key) => {
var newKey = this.xmlKeys[key];
this.root[newKey] = value;
delete this.root[key];
});
this[this.rootKey] = this.root;
delete this.root;
}
}
}