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

Avoiding invalid html #1342

Closed
smmoosavi opened this issue Nov 13, 2015 · 8 comments · Fixed by riot/compiler#59
Closed

Avoiding invalid html #1342

smmoosavi opened this issue Nov 13, 2015 · 8 comments · Fixed by riot/compiler#59

Comments

@smmoosavi
Copy link

As I see, created htmls by riot is invalid (https://validator.w3.org/)

For example:

Error: Element todo not allowed as child of element body in this context.

Can we include tags without invalid htmls or extraneous tags?

@cognitom
Copy link
Member

@smmoosavi a short answer is "no".

Custom elements are still editor's draft, so there's no official validator AFAIK.
http://w3c.github.io/webcomponents/spec/custom/
This draft says that the name of custom tag

must contain a U+002D HYPHEN-MINUS character

It would be safe to change todo to app-todo or something if you prefer to follow this spec.

There's a way to mount them as normal tags:

<div riot-tag="todo"></div>

but, riot-tag is not allowed as an attr of div in spec, so it'll not pass the validator, too, unfortunately.

@cognitom
Copy link
Member

Some comparative information for later discussion:

Vue's way is not fit to Riot.js. Normalization like Angular would be nice. Thoughts? @rsbondi

@smmoosavi
Copy link
Author

Ok.

I can't find including custom tags implementation in codes. So I say my idea with jquery. (can you say where is implimentations?)

In jquery contents function return inner nodes of some tag, and replaceWith function replace some elements with other elements.

if you replace contents of tag implementation with include statement it works correctly

<item id="def">
  <b>abc</b>
</item>

<div> <!-- usage -->
  <item id="use1"></item>
  <item id="use2"></item>
</div>

and js do some things equal to:

var $def = $('#def').contents();
$("#use1").replaceWith($def);
$("#use2").replaceWith($def);

result:

<div>
  <b>abc</b>
  <b>abc</b>
</div>

@cognitom
Copy link
Member

@smmoosavi your example doesn't make sense for me...
Could you check compiler and tmpl?
Riot v2.3 has split into several repos, FYI.

@georgir
Copy link

georgir commented Nov 14, 2015

I don't see why you say vue's way is not fit for riot. Just this.root.removeAttribute('riot-tag') on mount event. You can also mix it in with a mixin.
Should be possible for if and each too, though i've not looked into where and how exactly. Or just use virtual tag for them. if and each are already being removed by riot

edit: and just for the root tag there's also the last two forms of riot.mount http://riotjs.com/api/#mount-tag

@GianlucaGuarini
Copy link
Member

@georgir You should not forget that all the riot tags get styled using [riot-tag="item"] { color: red } so we can not simply remove the riot-tag attributes

@gregorypratt
Copy link
Contributor

Could we add support for a data-riot-tag attribute that would pass W3C?

aMarCruz pushed a commit to riot/compiler that referenced this issue Mar 8, 2016
- Fix [riot#1325](riot/riot#1325) : Gulp + Browserify + Babelify + type="es6" error.
- Fix [riot#1342](riot/riot#1342), [riot#1636](riot/riot#1636) and request from [dwyl/learn-riot#8](dwyl/learn-riot#8) : Server-Side Rendered Page Fails W3C Check. The new `data-is` attribute is used for scoped styles in addition to `riot-tag` (the later will be removed in compiler v3.x)
- The keyword `defer` in `<script src=file>` avoids that the compiler loads the file, preserving the tag - Requested by [riot#1492](riot/riot#1492) : Stop script tags from being evaluated with serverside `riot.render`. It is removed in client-side compilation because browsers will not load scripts through innerHTML.
- It has changed the character used to hide expressions during the compilation, maybe this fix [riot#1588](riot/riot#1588) : Syntax Error: Invalid character `\0129` (riot+compiler.min).
- Removed the unused parameter with the compiled-time brackets from the call to `riot.tag2`.
- Removed support for raw expressions. It is unlikely this feature will be implemented in v2.3.x
- Update devDependencies.
@GianlucaGuarini
Copy link
Member

fixed in riot@2.3.17 use the attribute data-is

aMarCruz pushed a commit to riot/compiler that referenced this issue Mar 10, 2016
- The parsers are moved to its own directory in the node version. The load is on first use.
- Fix [riot#1325](riot/riot#1325) : Gulp + Browserify + Babelify + type="es6" error.
- Fix [riot#1342](riot/riot#1342), [riot#1636](riot/riot#1636) and request from [dwyl/learn-riot#8](dwyl/learn-riot#8) : Server-Side Rendered Page Fails W3C Check. The new `data-is` attribute is used for scoped styles in addition to `riot-tag` (the later will be removed in compiler v3.x)
- The keyword `defer` in `<script src=file>` avoids that the compiler loads the file, preserving the tag - Requested by [riot#1492](riot/riot#1492) : Stop script tags from being evaluated with serverside `riot.render`. It is removed in client-side compilation because browsers will not load scripts through innerHTML.
- It has changed the character used to hide expressions during the compilation, maybe this fix [riot#1588](riot/riot#1588) : Syntax Error: Invalid character `\0129` (riot+compiler.min).
- The option `debug` inserts newlines between the `riot.tag2` parameters and the call is prefixed with the source filename - Requested by [riot#1646](riot/riot#1646) : Split portions of generated html with newline instead of space
- Removed the unused parameter with the compiled-time brackets from the call to `riot.tag2`.
- Removed support for raw expressions. It is unlikely this feature will be implemented in v2.3.x
- Updated the regex that is used to match tag names, more closer to the HTML5 specs.
- Update devDependencies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants