Merge branch 'master' of github.com:dolanmiu/docx

This commit is contained in:
Dolan
2019-03-06 22:53:23 +00:00
2 changed files with 3 additions and 2 deletions

View File

@ -15,6 +15,7 @@ class TableWidthAttributes extends XmlAttributeComponent<ITableWidth> {
export class PreferredTableWidth extends XmlComponent {
constructor(type: WidthType, w: number) {
super("w:tblW");
this.root.push(new TableWidthAttributes({ type, w }));
const width: number | string = type === WidthType.PERCENTAGE ? `${w}%` : w;
this.root.push(new TableWidthAttributes({ type: type, w: width }));
}
}

View File

@ -200,7 +200,7 @@ describe("Table", () => {
.which.is.an("array")
.with.has.length.at.least(1);
expect(tree["w:tbl"][0]).to.deep.equal({
"w:tblPr": [DEFAULT_TABLE_PROPERTIES, { "w:tblW": [{ _attr: { "w:type": "pct", "w:w": 1000 } }] }],
"w:tblPr": [DEFAULT_TABLE_PROPERTIES, { "w:tblW": [{ _attr: { "w:type": "pct", "w:w": "1000%" } }] }],
});
});