-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler-dom): fix in-browser attribute value decoding w/ html tags
fix #3001
- Loading branch information
Showing
2 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
packages/compiler-dom/__tests__/decoderHtmlBrowser.spec.ts
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,41 @@ | ||
import { decodeHtmlBrowser } from '../src/decodeHtmlBrowser' | ||
|
||
describe('decodeHtmlBrowser', () => { | ||
it('should decode HTML correctly', () => { | ||
expect(decodeHtmlBrowser(' abc 123 ')).toBe(' abc 123 ') | ||
|
||
expect(decodeHtmlBrowser('&')).toBe('&') | ||
expect(decodeHtmlBrowser('&')).toBe('&') | ||
expect(decodeHtmlBrowser('&')).toBe('&') | ||
|
||
expect(decodeHtmlBrowser('<')).toBe('<') | ||
expect(decodeHtmlBrowser('<')).toBe('<') | ||
expect(decodeHtmlBrowser('&lt;')).toBe('<') | ||
|
||
expect(decodeHtmlBrowser('>')).toBe('>') | ||
expect(decodeHtmlBrowser('>')).toBe('>') | ||
expect(decodeHtmlBrowser('&gt;')).toBe('>') | ||
|
||
expect(decodeHtmlBrowser(' ')).toBe('\u00a0') | ||
expect(decodeHtmlBrowser('"')).toBe('"') | ||
expect(decodeHtmlBrowser(''')).toBe("'") | ||
|
||
expect(decodeHtmlBrowser('É')).toBe('\u00c9') | ||
expect(decodeHtmlBrowser('É')).toBe('\u00c9') | ||
expect(decodeHtmlBrowser('É')).toBe('\u00c9') | ||
|
||
// #3001 html tags inside attribute values | ||
expect(decodeHtmlBrowser('<strong>Text</strong>', true)).toBe( | ||
'<strong>Text</strong>' | ||
) | ||
expect(decodeHtmlBrowser('<strong>&</strong>', true)).toBe( | ||
'<strong>&</strong>' | ||
) | ||
expect( | ||
decodeHtmlBrowser( | ||
'<strong><strong>&</strong></strong>', | ||
true | ||
) | ||
).toBe('<strong><strong>&</strong></strong>') | ||
}) | ||
}) |
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