哪些构造函数,如`new Image()`和`new Option()`,记录在案? [英] Where are constructors such as, `new Image()` and `new Option()`, documented?

查看:90
本文介绍了哪些构造函数,如`new Image()`和`new Option()`,记录在案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不在Mozilla,但是





给定这些引用, mozilla.org ,如下所述,文件一样。






具体来说,在 mozilla.org 中的构造函数是 new Image() new选项()在当代语境中记录?



古代文档





描述这些构造函数的存在,将它们作为内在的JavaScript语言组件,这是不正确的。

  javascript:alert([new Image ),'\\\
\\\
',new Option()])

存在通过显示


[object HTMLImageElement],



,[object HTMLOptionElement]


修辞,如何:

  javascript:alert([new Anchor(),new Preserve(),new Form(),,,])

还有什么其他原始的元素DOM构造函数?或者,还有没有更多?



是否与Mozilla使用的DOM范例不一致,并入新的编程定义Image() new Option()等,解释他们的缺席?然而,这些构造函数显然不是JavaScript的语言规范所固有的,当然不是HTML。那么,究竟有什么正确的当前模式(源自 mozilla.org ),它们完全描述它们,包括参数类型和订单?



参考文献:








另外:(请不要因此而分心 - 查找文章标题中指定的相关文件是唯一的考虑)



这个 提示您进行以下检查。这只是一个观察。

  javascript:
alert([Option,Image,
JSON,Math ,
Array,Boolean,Date,Function,
Number,Object,RegExp,String] .join(\\\
\\\
));
alert(Image.toSource());

在FireFox中生产:


[object Option]



[object Image]



[object JSON]



[object Math]



function Error(){
[native code]}



function Array(){
[native code]}



function Boolean(){
[native代码]}



function Date(){
[native code]}



function Function ){
[native code]}



function Number(){
[native code]}



function Object(){
[native code]}



function RegExp(){
[native code]}

function String(){
[native code]}



({})


但是

 错误:({} )不是一个构造函数
源文件:javascript:alert(new({}));
行:1

图像是否是构造函数? (可能)答案可以在回答这个帖子标题中提出的问题的文件中找到。这应该强调在适当的文件中编目 Image Option 等的不一致,异常和不规则。

解决方案

JavaScript™(Mozilla的另一种DOMAS操作的ECMAScript实现,也称为Gecko)与通用术语javascript用于描述其他浏览器中的类似脚本环境(例如IE中的JScript)。


古典文档,
[ 。]
描述了这些构造函数的存在,将它们称为
内在JavaScript语言组件,这是不正确的。


你如何得出这个结论? JavaScript™属于Mozilla,所以他们可以指定它包含任何他们想要的。 JavaScript™自从开始就有一个Image和Option构造函数,其他实现已经复制了它们,使得现有的每个浏览器都具有它们。 W3C DOM接口的创建之前存在这样的功能,而在无处不在的情况下,它们被标记为DOM 0,这真的意味着Netscape Navigator和Internet Explorer在DOM 1时支持。



DOM 0没有在任何地方正式记录。 HTML5是试图在浏览器中实现HTML和javascript的规范,因此它包括Image和Option构造函数,因此包括DOM 0功能,但是它们没有被标记或分类为这样。



[...]


然而,这些构造函数显然不是语言的固有
规范的JavaScript


没有发布JavaScript™的规范,只有JavaScript文档位于 Mozilla开发人员网络(MDN)。另请注意,MDN中的文档是任何可以创建和编辑的公共wiki,包括您。 : - )



您误以为Mozilla中的文档是JavaScript™的一种完整规范 - 不是。不是很长的路。这真的只是感兴趣的人添加的文档,主要是通过在浏览器周围戳,看看它的作用。还有一个 JavaScript参考,但您也可能会发现缺少。



[...]


HTMLImageElement Mozilla文档


指向Gecko DOM参考的链接记录了W3C HTMLImageElementInterface的JavaScript实现,它没有图像构造函数。


Mozilla中Image()构造函数的当代先例


这表明它存在,但没有方便的地方记录它。 JavaScript参考中可能会最好地记录。如果您想添加它,请获取一个MDN帐户(免费,非常简单)并添加。



编辑



现在,MDN中有一个图像文章链接到相关标准。



编辑2015年5月25日



Option构造函数是


Not at Mozilla but:

Given these references, it is moot whether mozilla.org, as asked below, documents the same.


Specifically, where at mozilla.org are constructors like new Image() and new Option() documented in a contemporary context?

Archaic documentation,

describes the existence of these constructors implicating them as intrinsic JavaScript language components, which is incorrect.

javascript: alert([new Image(), '\n\n', new  Option()])

clearly indicates their manifest existence by displaying

[object HTMLImageElement],

,[object HTMLOptionElement]

Rhetorically, what about:

javascript:alert([new Anchor(), new Preserve(), new Form(),,, ])

What other primitive elemental DOM constructors are there? Or, are there no more?

Is it anathema to, and inconsistent with the DOM paradigm used by Mozilla, to incorporate the programming definitions of new Image() and new Option() etc., explaining their absence? Yet, these constructors are clearly not intrinsic to the language specification of JavaScript and certainly not HTML. So, where exactly is there a correct current paradigm (originating from mozilla.org) that describes them fully, including argument types and orders?

references:


An aside: (please do not be distracted by this - locating the relevant documents as specified in the article's title is the only consideration)

This answer prompted the following examination. It is only an observation.

javascript:
    alert([  Option, Image,
               JSON, Math, Error, 
                 Array, Boolean, Date, Function,
                   Number, Object, RegExp, String  ].join("\n\n"));
    alert( Image.toSource() );

produces in FireFox:

[object Option]

[object Image]

[object JSON]

[object Math]

function Error() { [native code] }

function Array() { [native code] }

function Boolean() { [native code] }

function Date() { [native code] }

function Function() { [native code] }

function Number() { [native code] }

function Object() { [native code] }

function RegExp() { [native code] }

function String() { [native code] }

and

({})

but

Error: ({}) is not a constructor
Source File: javascript:alert(new ({}));
Line: 1

Is Image a constructor or not? The answer to this would (presumably) be found in the documents that answer the question asked in this posting's title. This should emphasize the inconsistencies, anomalies and irregularities of cataloging Image and Option etc. in an appropriate document.

解决方案

There is a distinction between JavaScript™ (the implementation of ECMAScript for DOM manipulation by Mozilla, aka Gecko) and the generic term "javascript" that is used to describe similar scripting environments in other browsers (e.g. JScript in IE).

Archaic documentation, [...] describes the existence of these constructors implicating them as intrinsic JavaScript language components, which is incorrect.

How do you come to that conclusion? JavaScript™ belongs to Mozilla so they can specify that it contains whatever they want. JavaScript™ has had an Image and Option constructor since the very beginning, other implementations have copied them so that every browser in existence has them. Such features existed before the creation of the W3C DOM interfaces and, where ubiquitous, are labelled "DOM 0", which really means were supported by Netscape Navigator and Internet Explorer at the time of DOM 1.

DOM 0 is not officially documented anywhere. HTML5 is an attempt at writing a specification for HTML and javascript as is implemented in browsers, so it includes both the Image and Option constructors and so includes DOM 0 features, but they aren't labelled or classified as such.

[...]

Yet, these constructors are clearly not intrinsic to the language specification of JavaScript

There is no published specification for JavaScript™, there is only the JavaScript documentation at Mozilla Developer Network (MDN). Also note that the documentation at MDN is a public wiki that anyone can create and edit, including you. :-)

You are mistaken in believing that the documentation at Mozilla is some kind of complete specification for JavaScript™—it isn't. Not by a long way. It is really just documentation that has been added by interested persons, mostly by poking around the browser and seeing what it does. There is also a JavaScript Reference, but you may also find that lacking.

[...]

HTMLImageElement Mozilla documentation

That link to the the Gecko DOM reference documents the JavaScript implementation of the W3C HTMLImageElementInterface which does not have an Image constructor.

Contemporary precedent for Image() constructor use at Mozilla

Which indicates that it exists, but there is no convenient place to document it. It might be best documented in the JavaScript Reference. If you wish to add it, get an MDN account (free, very easy) and add it.

Edit

There is now an Image article at MDN that links to relevant standards.

Edit 25 May 2015

The Option constructor is documented in HTML5.

这篇关于哪些构造函数,如`new Image()`和`new Option()`,记录在案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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