Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont set background color if none is provided in options #1285

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import { DocumentBackground } from "./document-background";

describe("DocumentBackground", () => {
describe("#constructor()", () => {
it("should create a DocumentBackground with no options and set color to auto", () => {
it("should create a DocumentBackground with no options", () => {
const documentBackground = new DocumentBackground({});
const tree = new Formatter().format(documentBackground);
expect(tree).to.deep.equal({
"w:background": {
_attr: {
"w:color": "FFFFFF",
},
_attr: {},
},
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/file/document/document-background/document-background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
// </xsd:simpleType>

export class DocumentBackgroundAttributes extends XmlAttributeComponent<{
readonly color: string;
readonly color?: string;
readonly themeColor?: string;
readonly themeShade?: string;
readonly themeTint?: string;
Expand Down Expand Up @@ -68,7 +68,7 @@ export class DocumentBackground extends XmlComponent {

this.root.push(
new DocumentBackgroundAttributes({
color: hexColorValue(options.color ? options.color : "FFFFFF"),
color: options.color === undefined ? undefined : hexColorValue(options.color),
themeColor: options.themeColor,
themeShade: options.themeShade === undefined ? undefined : uCharHexNumber(options.themeShade),
themeTint: options.themeTint === undefined ? undefined : uCharHexNumber(options.themeTint),
Expand Down
4 changes: 1 addition & 3 deletions src/file/document/document.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ describe("Document", () => {
},
{
"w:background": {
_attr: {
"w:color": "FFFFFF",
},
_attr: {},
},
},
{ "w:body": {} },
Expand Down