diff --git a/src/file/styles/external-styles-factory.spec.ts b/src/file/styles/external-styles-factory.spec.ts index 2ddc849ae8..9db766008b 100644 --- a/src/file/styles/external-styles-factory.spec.ts +++ b/src/file/styles/external-styles-factory.spec.ts @@ -62,19 +62,14 @@ describe("External styles factory", () => { // tslint:disable-next-line:no-any const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any; expect(importedStyle.root[1]).to.deep.equal({ - deleted: false, root: [ { - deleted: false, root: [ { - deleted: false, root: [ { - deleted: false, root: [ { - deleted: false, root: { "w:ascii": "Arial", "w:cstheme": "minorHAnsi", @@ -87,10 +82,8 @@ describe("External styles factory", () => { rootKey: "w:rFonts", }, { - deleted: false, root: [ { - deleted: false, root: { "w:bidi": "ar-SA", "w:eastAsia": "en-US", @@ -108,16 +101,12 @@ describe("External styles factory", () => { rootKey: "w:rPrDefault", }, { - deleted: false, root: [ { - deleted: false, root: [ { - deleted: false, root: [ { - deleted: false, root: { "w:after": "160", "w:line": "259", @@ -138,10 +127,8 @@ describe("External styles factory", () => { rootKey: "w:docDefaults", }); expect(importedStyle.root[2]).to.deep.equal({ - deleted: false, root: [ { - deleted: false, root: { "w:defLockedState": "1", "w:defUIPriority": "99", @@ -165,10 +152,8 @@ describe("External styles factory", () => { expect(importedStyle.root.length).to.equal(5); expect(importedStyle.root[3]).to.deep.equal({ - deleted: false, root: [ { - deleted: false, root: { "w:default": "1", "w:styleId": "Normal", @@ -177,10 +162,8 @@ describe("External styles factory", () => { rootKey: "_attr", }, { - deleted: false, root: [ { - deleted: false, root: { "w:val": "Normal", }, @@ -190,7 +173,6 @@ describe("External styles factory", () => { rootKey: "w:name", }, { - deleted: false, root: [], rootKey: "w:qFormat", }, @@ -199,10 +181,8 @@ describe("External styles factory", () => { }); expect(importedStyle.root[4]).to.deep.equal({ - deleted: false, root: [ { - deleted: false, root: { "w:styleId": "Heading1", "w:type": "paragraph", @@ -210,10 +190,8 @@ describe("External styles factory", () => { rootKey: "_attr", }, { - deleted: false, root: [ { - deleted: false, root: { "w:val": "heading 1", }, @@ -223,10 +201,8 @@ describe("External styles factory", () => { rootKey: "w:name", }, { - deleted: false, root: [ { - deleted: false, root: { "w:val": "Normal", }, @@ -236,26 +212,20 @@ describe("External styles factory", () => { rootKey: "w:basedOn", }, { - deleted: false, root: [ { - deleted: false, root: [], rootKey: "w:keepNext", }, { - deleted: false, root: [], rootKey: "w:keepLines", }, { - deleted: false, root: [ { - deleted: false, root: [ { - deleted: false, root: { "w:color": "auto", "w:space": "1", diff --git a/src/file/xml-components/base.ts b/src/file/xml-components/base.ts index 375e30d910..7a0d5a758b 100644 --- a/src/file/xml-components/base.ts +++ b/src/file/xml-components/base.ts @@ -9,16 +9,10 @@ export interface IContext { export abstract class BaseXmlComponent { protected readonly rootKey: string; - // tslint:disable-next-line:readonly-keyword - protected deleted: boolean = false; constructor(rootKey: string) { this.rootKey = rootKey; } public abstract prepForXml(context: IContext): IXmlableObject | undefined; - - public get IsDeleted(): boolean { - return this.deleted; - } } diff --git a/src/file/xml-components/imported-xml-component.spec.ts b/src/file/xml-components/imported-xml-component.spec.ts index 0f590b1286..58c07d09ca 100644 --- a/src/file/xml-components/imported-xml-component.spec.ts +++ b/src/file/xml-components/imported-xml-component.spec.ts @@ -20,28 +20,24 @@ const xmlString = ` `; const convertedXmlElement = { - deleted: false, root: [ { - deleted: false, rootKey: "w:p", root: [ - { deleted: false, rootKey: "_attr", root: { "w:one": "value 1", "w:two": "value 2" } }, - { deleted: false, rootKey: "w:rPr", root: [{ deleted: false, rootKey: "w:noProof", root: ["some value"] }] }, + { rootKey: "_attr", root: { "w:one": "value 1", "w:two": "value 2" } }, + { rootKey: "w:rPr", root: [{ rootKey: "w:noProof", root: ["some value"] }] }, { - deleted: false, rootKey: "w:r", root: [ - { deleted: false, rootKey: "_attr", root: { active: "true" } }, - { deleted: false, rootKey: "w:t", root: ["Text 1"] }, + { rootKey: "_attr", root: { active: "true" } }, + { rootKey: "w:t", root: ["Text 1"] }, ], }, { - deleted: false, rootKey: "w:r", root: [ - { deleted: false, rootKey: "_attr", root: { active: "true" } }, - { deleted: false, rootKey: "w:t", root: ["Text 2"] }, + { rootKey: "_attr", root: { active: "true" } }, + { rootKey: "w:t", root: ["Text 2"] }, ], }, ], diff --git a/src/file/xml-components/xml-component.spec.ts b/src/file/xml-components/xml-component.spec.ts index 4fa5bfc515..c1b4f5d053 100644 --- a/src/file/xml-components/xml-component.spec.ts +++ b/src/file/xml-components/xml-component.spec.ts @@ -1,8 +1,7 @@ import { expect } from "chai"; import { Formatter } from "export/formatter"; -import { EMPTY_OBJECT, XmlComponent } from "./"; -import { IContext } from "./base"; +import { XmlComponent } from "./"; class TestComponent extends XmlComponent {} @@ -21,21 +20,4 @@ describe("XmlComponent", () => { }); }); }); - - describe("#prepForXml()", () => { - it("should skip deleted elements", () => { - const child = new TestComponent("w:test1"); - child.delete(); - xmlComponent.addChildElement(child); - - // tslint:disable-next-line: no-object-literal-type-assertion - const xml = xmlComponent.prepForXml({} as IContext); - - if (!xml) { - return; - } - - expect(xml["w:test"]).to.deep.equal(EMPTY_OBJECT); - }); - }); }); diff --git a/src/file/xml-components/xml-component.ts b/src/file/xml-components/xml-component.ts index a4e77b30a6..e4176a3a91 100644 --- a/src/file/xml-components/xml-component.ts +++ b/src/file/xml-components/xml-component.ts @@ -14,12 +14,6 @@ export abstract class XmlComponent extends BaseXmlComponent { public prepForXml(context: IContext): IXmlableObject | undefined { const children = this.root - .filter((c) => { - if (c instanceof BaseXmlComponent) { - return !c.IsDeleted; - } - return c !== undefined; - }) .map((comp) => { if (comp instanceof BaseXmlComponent) { return comp.prepForXml(context); @@ -44,10 +38,6 @@ export abstract class XmlComponent extends BaseXmlComponent { return this; } - - public delete(): void { - this.deleted = true; - } } export abstract class IgnoreIfEmptyXmlComponent extends XmlComponent {