-
-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix replacer error on patches with empty Runs (#2875)
* Add test to demonstrate empty strings not creating runs * Fix Run not creating Text child for empty strings * Simplify TextRun constructor Since `Run` already has a option for instantiating a `Text` element, we don't need to push children here. * Add replacer test for empty runs * Add replacer test for empty runs * replacer: handle patches with empty runs * Fix incorrect test name
- Loading branch information
Showing
5 changed files
with
78 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,7 @@ | ||
import { IRunOptions, Run } from "./run"; | ||
import { Text } from "./run-components/text"; | ||
|
||
export class TextRun extends Run { | ||
public constructor(options: IRunOptions | string) { | ||
if (typeof options === "string") { | ||
super({}); | ||
this.root.push(new Text(options)); | ||
return this; | ||
} | ||
|
||
super(options); | ||
super(typeof options === "string" ? { text: options } : options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters