Fix styling and linting
This commit is contained in:
@ -10,7 +10,7 @@ export abstract class BaseXmlComponent {
|
||||
|
||||
public abstract prepForXml(): IXmlableObject;
|
||||
|
||||
get isDeleted() {
|
||||
public get isDeleted(): boolean {
|
||||
return this.deleted;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,17 @@
|
||||
import { XmlComponent, IXmlableObject } from ".";
|
||||
// tslint:disable:no-any
|
||||
import { IXmlableObject, XmlComponent } from "./";
|
||||
|
||||
/**
|
||||
* Represents imported xml component from xml file.
|
||||
*/
|
||||
export class ImportedXmlComponent extends XmlComponent {
|
||||
private _attr: any;
|
||||
private attr: any;
|
||||
|
||||
constructor(rootKey: string, _attr?: any) {
|
||||
constructor(rootKey: string, attr?: any) {
|
||||
super(rootKey);
|
||||
if (_attr) {
|
||||
this._attr = _attr;
|
||||
|
||||
if (attr) {
|
||||
this.attr = attr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,18 +41,18 @@ export class ImportedXmlComponent extends XmlComponent {
|
||||
* ]
|
||||
* }
|
||||
*/
|
||||
prepForXml(): IXmlableObject {
|
||||
public prepForXml(): IXmlableObject {
|
||||
const result = super.prepForXml();
|
||||
if (!!this._attr) {
|
||||
if (!!this.attr) {
|
||||
if (!Array.isArray(result[this.rootKey])) {
|
||||
result[this.rootKey] = [result[this.rootKey]];
|
||||
}
|
||||
result[this.rootKey].unshift({ _attr: this._attr });
|
||||
result[this.rootKey].unshift({ _attr: this.attr });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
push(xmlComponent: XmlComponent) {
|
||||
public push(xmlComponent: XmlComponent): void {
|
||||
this.root.push(xmlComponent);
|
||||
}
|
||||
}
|
||||
@ -59,13 +61,13 @@ export class ImportedXmlComponent extends XmlComponent {
|
||||
* Used for the attributes of root element that is being imported.
|
||||
*/
|
||||
export class ImportedRootElementAttributes extends XmlComponent {
|
||||
constructor(private _attr: any) {
|
||||
constructor(private attr: any) {
|
||||
super("");
|
||||
}
|
||||
|
||||
public prepForXml(): IXmlableObject {
|
||||
return {
|
||||
_attr: this._attr,
|
||||
_attr: this.attr,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
export * from "./xml-component";
|
||||
export * from "./attributes";
|
||||
export * from "./default-attributes";
|
||||
export * from './imported-xml-component';
|
||||
export * from "./imported-xml-component";
|
||||
export * from "./xmlable-object";
|
||||
|
@ -24,9 +24,9 @@ describe("XmlComponent", () => {
|
||||
const child = new TestComponent("w:test1");
|
||||
child.delete();
|
||||
xmlComponent.addChildElement(child);
|
||||
|
||||
|
||||
const xml = xmlComponent.prepForXml();
|
||||
assert.equal(xml['w:test'].length, 0);
|
||||
assert.equal(xml["w:test"].length, 0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -12,7 +12,7 @@ export abstract class XmlComponent extends BaseXmlComponent {
|
||||
|
||||
public prepForXml(): IXmlableObject {
|
||||
const children = this.root
|
||||
.filter(c => {
|
||||
.filter((c) => {
|
||||
if (c instanceof BaseXmlComponent) {
|
||||
return !c.isDeleted;
|
||||
}
|
||||
@ -30,11 +30,14 @@ export abstract class XmlComponent extends BaseXmlComponent {
|
||||
};
|
||||
}
|
||||
|
||||
public addChildElement(child: XmlComponent | string) {
|
||||
// TODO: Unused method
|
||||
public addChildElement(child: XmlComponent | string): XmlComponent {
|
||||
this.root.push(child);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public delete() {
|
||||
public delete(): void {
|
||||
this.deleted = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user