Html Eclipse 中有效 HTML5 属性的警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4193905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:18:02  来源:igfitidea点击:

Warnings of valid HTML5 attributes in Eclipse

eclipsehtml

提问by Tim

I use Eclipse and I write jsp files with HTML5 content. So I have for example this line:

我使用 Eclipse 并编写带有 HTML5 内容的 jsp 文件。所以我有例如这一行:

<div class="test" data-role="test123">

In Eclipse I get the warning:

在 Eclipse 中,我收到警告:

Undefined attribute name (data-role)

What needed to be done so these warnings won't appear anymore? In HTML5 this attribute is allowed (data-*) as you can see here: http://ejohn.org/blog/html-5-data-attributes/

需要做什么才能使这些警告不再出现?在 HTML5 中,此属性是允许的 (data-*),如您所见:http: //ejohn.org/blog/html-5-data-attributes/

Best Regards.

此致。

回答by Redtama

It seems like Eclipse still has some problems validating HTML5 elements and attributes even now.

即使现在,Eclipse 在验证 HTML5 元素和属性方面似乎仍然存在一些问题。

I'm running Mars 4.5.1 and I have had warnings about the <main>element, despite the fact that there are no warnings about the <section>element.

我正在运行 Mars 4.5.1 并且我收到了关于该<main>元素的警告,尽管事实上没有关于该<section>元素的警告。

But there is a solution!

但是有一个解决方案!

Window > Preferences > Web > HTML Files > Validation

Window >Preferences >Web >HTML Files >Validation

窗口 >首选项 >Web >HTML 文件 >验证

Here you can tick the Ignore specified element names in validationcheckbox and enter the names of any elements which Eclipse is incorrectly warning you about.

在这里,您可以勾选Ignore specified element names in validation复选框并输入 Eclipse 错误警告您的任何元素的名称。

In your case, you will want to tick the Ignore specified attribute names in validationcheckbox and enter the data-roleattribute.

在您的情况下,您需要勾选Ignore specified attribute names in validation复选框并输入data-role属性。

After you click 'Apply', Eclipse will ask you to do a full validation of the project. Select 'Yes' and the changes will take effect.

单击“应用”后,Eclipse 将要求您对项目进行全面验证。选择“是”,更改将生效。

No more squiggly yellow lines YAY! :D

没有更多弯曲的黄线 YAY!:D

回答by MS Ibrahim

Your doctype

你的文档类型

is for HTML 4.01.

适用于 HTML 4.01。

data-* attributes were added in HTML 5. The doctype for HTML 5 is basically either

在 HTML 5 中添加了 data-* 属性。 HTML 5 的文档类型基本上是

<!DOCTYPE html SYSTEM "about:legacy-compat">

or

或者

<!DOCTYPE html>

回答by Josh Habdas

Newer versions of Eclipse support HTML5 tags and the data-* attributes allowed in HTML5. However, when using the role attribute the proper syntax according to the ARIA Roles Modeland XHTML Role Attribute Moduleis not to prefix the role attribute with data-*leaving just role and not data-role.

较新版本的 Eclipse 支持 HTML5 标记和 HTML5 中允许的 data-* 属性。然而,当使用角色属性时,根据ARIA 角色模型XHTML 角色属性模块的正确语法是不要在角色属性前加上 data-*,只留下角色而不是数据角色。

So <ul role="menubar">is more correct than <ul data-role="menubar">. The validity of the syntax can be checked using the (X)HTML5 Validator. jQuery Mobile uses quite extensively the data-role attribute, though I'm not sure why.

所以<ul role="menubar">比 更正确<ul data-role="menubar">。可以使用(X)HTML5 Validator检查语法的有效性。jQuery Mobile 非常广泛地使用 data-role 属性,但我不知道为什么。

Note:If you upgrade and you're still getting warnings on data-* attributes you may want to consider updating or removing any installed syntax-checkers such as JTidy. As of Indigo Service Release 1 the role attribute continues to trigger an undefined attribute warning in Eclipse by default.

注意:如果升级后仍然收到有关 data-* 属性的警告,您可能需要考虑更新或删除任何已安装的语法检查程序,例如 JTidy。从 Indigo Service Release 1 开始,默认情况下,角色属性继续在 Eclipse 中触发未定义属性警告。

回答by vanduc1102

I used this one with Aptana 3.6 when I'am coding AngularJS

当我编写 AngularJS 代码时,我在 Aptana 3.6 中使用了这个

Window > Preferences

窗口 > 首选项

Choose Ignore Proprietary Attributes

选择忽略专有属性

回答by TMB

I use the Aptana Studio pluginon Mac OS X; if I go Eclipse > Preferences > Aptana Studio > Validation > HTML, and create the filter *data-role*I no longer get this warning.

我在 Mac OS X 上使用Aptana Studio 插件;如果我去Eclipse > Preferences > Aptana Studio > Validation > HTML并创建过滤器,*data-role*我将不再收到此警告。

I believe on Windows it is Window > Preferences > Aptana Studio > Validation > HTML

我相信在 Windows 上它是 Window > Preferences > Aptana Studio > Validation > HTML

Aptana HTML Validation

Aptana HTML 验证

回答by vallismortis

Eclipse 3.6 introduced a new field under:

Eclipse 3.6 在下面引入了一个新字段:

Validation -> HTML Syntax: Ignore specified attribute names in validation

Validation -> HTML Syntax: Ignore specified attribute names in validation

Add the OpenGraph, RDFa or other non-HTML5 attributes you want the validator to ignore:

添加您希望验证器忽略的 OpenGraph、RDFa 或其他非 HTML5 属性:

Ignore specified attribute names in validation

在验证中忽略指定的属性名称

You will need to re-validate the project, then the warnings will be gone.

您需要重新验证项目,然后警告就会消失。