<ui-select> 的 W3C 验证 [英] W3C validation for &lt;ui-select&gt;

查看:30
本文介绍了<ui-select> 的 W3C 验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个网站中使用 angular-ui-select,其中样式选择字段配置了自己的标签名为 ui-select.这很好用,但是执行 W3C 验证 会导致此错误:

<块引用>在此上下文中,

元素 ui-select 不允许作为元素 div 的子元素.(抑制来自此子树的更多错误.)

这是一个示例代码:

<html lang="zh-cn"><head><title>x</title></head><身体><div><ui-select></ui-select>

</body></html>

我知道 预计不会出现,但我该如何更好地处理这个问题?

我可以将它包装到不同的标签中吗,或者是否有不同的 ui-select 方法而不是使用 HTML 标记?

解决方案

这确实是 AngularJS 的一个长期存在的问题.

您可以做的一些事情:

您可以使用

而不是使用元素 ,但这仍然会在参数上失败.

x-data- 为前缀的参数会通过,但我不确定 ui-select 是否支持.

HTML W3C 验证很有用,但我认为对于 HTML 电子邮件最重要,因此它们不会被筛选为垃圾邮件.这对搜索引擎也有好处,但实际上并不那么重要.

如果您查看为什么要验证",原因主要是为了清洁,易于调试,总体良好做法.

Angular (un?) 幸运地扩展了 HTML5 的可能性范围,自然而然地偏离了 HTML 的最新规范.

I am using angular-ui-select within a website where the styled select fields are configured with an own tag named ui-select. This works great, but doing a W3C validation leads to this error:

Element ui-select not allowed as child of element div in this context. (Suppressing further errors from this subtree.)

Here's an example code:

<!doctype html>
<html lang="en">
<head><title>x</title></head>
<body>
 <div>
  <ui-select></ui-select>
 </div>
</body></html>

I understand that <ui-select> is not expected to be there but how can I handle this better?

Can I wrap it into a different tag or is there a different approach for ui-select instead of using HTML markup?

解决方案

That's indeed a long-known issue with AngularJS.

A few things you can do:

Instead of using the element <ui-select>, you can use <div ui-select>, but that will still fail on the argument.

An argument prefixed with x- or data- will pass but I am not sure ui-select supports that.

HTML W3C validation is useful, but I think mostly important for HTML emails so they don't get screened as spam. It's also good for search engines, but really not that critical.

If you look at 'why validate', the reasons are mostly for cleanliness, ease of debugging, and overall good practice.

Angular (un?)fortunately expands the realm of possibilities for HTML5, in a way that, naturally, deviates from the latest specifications for HTML.

这篇关于<ui-select> 的 W3C 验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆