-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bug #573] Ensure link href is preserved by annotator.
Link attributes are modified when rendering document in annotator. We need to ensure they are restored when saving the content.
- Loading branch information
Showing
5 changed files
with
82 additions
and
9 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
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Element } from "domhandler"; | ||
import HtmlParserUtils from "../HtmlParserUtils"; | ||
|
||
describe("HtmlParserUtils", () => { | ||
describe("html2dom", () => { | ||
it("remove target and rel attributes added when rendering HTML", () => { | ||
const html = | ||
'<a href="http://example.com" target="_blank" rel="noopener noreferrer">Example</a>'; | ||
const nodes = HtmlParserUtils.html2dom(html); | ||
expect((nodes[0] as Element).attribs.href).toEqual("http://example.com"); | ||
expect((nodes[0] as Element).attribs.target).not.toBeDefined(); | ||
expect((nodes[0] as Element).attribs.rel).not.toBeDefined(); | ||
}); | ||
|
||
it("set href attribute to data-href attribute created when rendering HTML", () => { | ||
const html = '<a data-href="./about.html">Example</a>'; | ||
const nodes = HtmlParserUtils.html2dom(html); | ||
expect((nodes[0] as Element).attribs.href).toEqual("./about.html"); | ||
expect((nodes[0] as Element).attribs["data-href"]).not.toBeDefined(); | ||
}); | ||
}); | ||
}); |
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