Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: capricorn86/happy-dom
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v10.10.2
Choose a base ref
...
head repository: capricorn86/happy-dom
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v10.10.3
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Aug 18, 2023

  1. Copy the full SHA
    3103e1f View commit details
  2. Merge pull request #1020 from capricorn86/task/999-innerhtml-parser-i…

    …nterprets-in-unquoted-element-attributes-incorrectly
    
    #999@patch: Adds support for URLs in attributes that doesn't use apos…
    capricorn86 authored Aug 18, 2023
    Copy the full SHA
    01fec13 View commit details
Showing with 9 additions and 1 deletion.
  1. +1 −1 packages/happy-dom/src/xml-parser/XMLParser.ts
  2. +8 −0 packages/happy-dom/test/xml-parser/XMLParser.test.ts
2 changes: 1 addition & 1 deletion packages/happy-dom/src/xml-parser/XMLParser.ts
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ const MARKUP_REGEXP =
* Group 9: Attribute name when the attribute has no value (e.g. "disabled" in "<div disabled>").
*/
const ATTRIBUTE_REGEXP =
/\s*([a-zA-Z0-9-_:.$@?]+) *= *([a-zA-Z0-9-_:.$@?{}]+)|\s*([a-zA-Z0-9-_:.$@?]+) *= *"([^"]*)("{0,1})|\s*([a-zA-Z0-9-_:.$@?]+) *= *'([^']*)('{0,1})|\s*([a-zA-Z0-9-_:.$@?]+)/gm;
/\s*([a-zA-Z0-9-_:.$@?]+) *= *([a-zA-Z0-9-_:.$@?{}/]+)|\s*([a-zA-Z0-9-_:.$@?]+) *= *"([^"]*)("{0,1})|\s*([a-zA-Z0-9-_:.$@?]+) *= *'([^']*)('{0,1})|\s*([a-zA-Z0-9-_:.$@?]+)/gm;

enum MarkupReadStateEnum {
startOrEndTag = 'startOrEndTag',
8 changes: 8 additions & 0 deletions packages/happy-dom/test/xml-parser/XMLParser.test.ts
Original file line number Diff line number Diff line change
@@ -669,6 +669,14 @@ describe('XMLParser', () => {
);
});

it('Parses attributes with URL without apostrophs.', () => {
const root = XMLParser.parse(document, `<a href=http://www.github.com/path>Click me</a>`);

expect(new XMLSerializer().serializeToString(root)).toBe(
'<a href="http://www.github.com/path">Click me</a>'
);
});

it('Parses attributes with single apostrophs.', () => {
const root = XMLParser.parse(document, `<div key1='value1' key2='value2'>Test</div>`);