Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(HtmlParser): mark <source> elements as void #5668

Conversation

pkozlowski-opensource
Copy link
Member

Fixes #5663

@pkozlowski-opensource
Copy link
Member Author

@vicb picked up this one to get (a bit) familiar with the new HTML parser code. Not sure what you think about having tests for each specific tags

@pkozlowski-opensource pkozlowski-opensource added the action: review The PR is still awaiting reviews from at least one requested reviewer label Dec 7, 2015
@vicb
Copy link
Contributor

vicb commented Dec 7, 2015

Not sure what you think about having tests for each specific tags

Not sure if it would be really useful - if you write the source and the tests, they would probably pass. however it doesn't hurt either.

There are also more void elements that are not currently covered, could you add them ? (http://www.w3.org/TR/html5/syntax.html#void-elements)

@vicb vicb added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Dec 7, 2015
@@ -369,6 +369,7 @@ var TAG_DEFINITIONS: {[key: string]: HtmlTagDefinition} = {
'rp': new HtmlTagDefinition({closedByChildren: ['rb', 'rt', 'rtc', 'rp'], closedByParent: true}),
'optgroup': new HtmlTagDefinition({closedByChildren: ['optgroup'], closedByParent: true}),
'option': new HtmlTagDefinition({closedByChildren: ['option', 'optgroup'], closedByParent: true}),
'source': new HtmlTagDefinition({requiredParents: ['audio', 'video'], isVoid: true}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requiredParents means that the first parent (audio) will be automatically added when none of them is present. I don't think it's like that in the spec, is it ?

@pkozlowski-opensource pkozlowski-opensource removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Dec 7, 2015
@pkozlowski-opensource
Copy link
Member Author

@vicb updated. Mind having another look?

// <command> - obsolete
// <keygen> - obsolete

humanizeDom(parser.parse('<map><area></map>', 'TestComp'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[
  'fix1',
  'fix2',
].forEach((html) => {
  expect(parser.parse(html, 'TestComp').errors).toEqual([]);
});

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -75,6 +75,22 @@ export function main() {
]);
});

it('should not error on void elements from HTML5 spec',
() => {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits:

  • remove the extra blank lines
  • have one fixture per line (I think that if you add a "," after the last element clang will not mess with the formatting)
  • close the .forEach() with a ;

@pkozlowski-opensource
Copy link
Member Author

@vicb clang-format seems to have very strong opinion about how things should work.... I'm not sure I find it easier to read now. But hey, this is why we've got formatter to make us all agree :-)

Feel free to fiddle more with the formatting if you've got an idea on making it look nicer

'<div><embed></div>', '<div><hr></div>', '<div><img></div>',
'<div><input></div>', '<object><param>/<object>', '<audio><source></audio>',
'<audio><track></audio>', '<p><wbr></p>',
].forEach((html) => { expect(parser.parse(html, 'TestComp').errors).toEqual([]); })});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

});}); missing ";"

@vicb
Copy link
Contributor

vicb commented Dec 8, 2015

LGTM

@vicb vicb added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Dec 8, 2015
@vicb vicb added this to the beta.0 milestone Dec 8, 2015
@mary-poppins
Copy link

Merging PR #5668 on behalf of @jelbourn to branch presubmit-jelbourn-pr-5668.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<source> tag throwing error since alpha.48 (d388c0a)
5 participants