html - WHATWG html5标准文档中idl属性是什么意思?

标签 html standards idl

在阅读 WHATWG 的 HTML5 - A technical specification for Web developers 时我看到很多引用资料,例如:

Reflecting content attributes in IDL attributes

Some IDL attributes are defined to reflect a particular content attribute. This means that on getting, the IDL attribute returns the current value of the content attribute, and on setting, the IDL attribute changes the value of the content attribute to the given value.

和:

In conforming documents, there is only one body element. The document.body IDL attribute provides scripts with easy access to a document's body element.

The body element exposes as event handler content attributes a number of the event handlers of the Window object. It also mirrors their event handler IDL attributes.

我的(公认的模糊)理解来自 Windows 世界。我认为 .idl 文件用于映射 n 层分布式应用程序中的远程过程调用。我假设内容属性是指 html 元素属性。

在标准我可以看到 中没有地方解释术语“内容属性”和“IDL 属性”的用法。谁能解释一下这些术语的含义以及这两种属性之间的关系?

最佳答案

IDL ( Interface Definition Language ) 来自 Web IDL规范:

This document defines an interface definition language, Web IDL, that can be used to describe interfaces that are intended to be implemented in web browsers. Web IDL is an IDL variant with a number of features that allow the behavior of common script objects in the web platform to be specified more readily. How interfaces described with Web IDL correspond to constructs within ECMAScript execution environments is also detailed in this document.

内容属性是出现在标记中的属性:

<div id="mydiv" class="example"></div>

在上面的代码中idclass是属性。通常一个内容属性会有一个对应的 IDL 属性。

例如,下面的 JavaScript:

document.getElementById('mydiv').className = 'example'

相当于设置class内容属性。

在 JavaScript 文本中,IDL 属性通常被称为属性,因为它们作为 DOM 对象的属性暴露给 JavaScript。

虽然通常有一对对应的内容属性和 IDL 属性/特性,但它们不一定可以互换。例如,对于 <option>元素:

  • 内容属性selected指示选项的初始状态(并且在用户更改选项时不会更改),
  • 属性(property) selected反射(reflect)控件的当前状态

关于html - WHATWG html5标准文档中idl属性是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12354918/

相关文章:

html - css 没有在网页上显示背景封面

java - Client.java :30: getThingToDo() in OtherPackage. TaskOperations 无法应用于(短)

c++ - 为什么 const 引用会延长右值的生命周期?

c - 下一个 C 标准的想法应该去哪里?

c++ - 为 Firefox 辅助功能编译 .IDL 文件后出错

inheritance - MIDL 中的结构继承

javascript - 当我单击提交按钮并在当前事件选项卡中触发图像

c# - 如何从代码隐藏的更新面板中找到客户端元素?

javascript - 如何使用 jQuery 在代码标记内添加 pre 标记?

c++ - 复数的平方根 - g++ vs icpc