Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
Copyright (c) 2010 Elijah Insua
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,611 @@
# jsdom
A JavaScript implementation of the WHATWG DOM and HTML standards, for use with [Node.js](https://nodejs.org/).
## Install
```bash
$ npm install jsdom
```
Note that as of our 7.0.0 release, jsdom requires Node.js 4 or newer ([why?](https://github.com/tmpvar/jsdom/blob/master/Changelog.md#700)). In the meantime you are still welcome to install a release in [the 3.x series](https://github.com/tmpvar/jsdom/tree/3.x) if you use legacy Node.js versions like 0.10 or 0.12. There are also various releases between 3.x and 7.0.0 that work with various io.js versions.
## Human contact
- [Mailing list](http://groups.google.com/group/jsdom)
- IRC channel: [#jsdom on freenode](irc://irc.freenode.net/jsdom)
## Easymode: `jsdom.env`
`jsdom.env` is an API that allows you to throw a bunch of stuff at it, and it will generally do the right thing.
You can use it with a URL
```js
// Count all of the links from the io.js build page
var jsdom = require("jsdom");
jsdom.env(
"https://iojs.org/dist/",
["http://code.jquery.com/jquery.js"],
function (err, window) {
console.log("there have been", window.$("a").length - 4, "io.js releases!");
}
);
```
or with raw HTML
```js
// Run some jQuery on a html fragment
var jsdom = require("jsdom");
jsdom.env(
'<p><a class="the-link" href="https://github.com/tmpvar/jsdom">jsdom!</a></p>',
["http://code.jquery.com/jquery.js"],
function (err, window) {
console.log("contents of a.the-link:", window.$("a.the-link").text());
}
);
```
or with a configuration object
```js
// Print all of the news items on Hacker News
var jsdom = require("jsdom");
jsdom.env({
url: "http://news.ycombinator.com/",
scripts: ["http://code.jquery.com/jquery.js"],
done: function (err, window) {
var $ = window.$;
console.log("HN Links");
$("td.title:not(:last) a").each(function() {
console.log(" -", $(this).text());
});
}
});
```
or with raw JavaScript source
```js
// Print all of the news items on Hacker News
var jsdom = require("jsdom");
var fs = require("fs");
var jquery = fs.readFileSync("./path/to/jquery.js", "utf-8");
jsdom.env({
url: "http://news.ycombinator.com/",
src: [jquery],
done: function (err, window) {
var $ = window.$;
console.log("HN Links");
$("td.title:not(:last) a").each(function () {
console.log(" -", $(this).text());
});
}
});
```
### How it works
The do-what-I-mean API is used like so:
```js
jsdom.env(string, [scripts], [config], callback);
```
- `string`: may be a URL, file name, or HTML fragment
- `scripts`: a string or array of strings, containing file names or URLs that will be inserted as `<script>` tags
- `config`: see below
- `callback`: takes two arguments
- `err`: either `null`, if nothing goes wrong, or an error, if the window could not be created
- `window`: a brand new `window`, if there wasn't an error
_Example:_
```js
jsdom.env(html, function (err, window) {
// free memory associated with the window
window.close();
});
```
If you would like to specify a configuration object only:
```js
jsdom.env(config);
```
- `config.html`: a HTML fragment
- `config.file`: a file which jsdom will load HTML from; the resulting document's URL will be a `file://` URL.
- `config.url`: sets the resulting document's URL, which is reflected in various properties like `document.URL` and `location.href`, and is also used for cross-origin request restrictions. If `config.html` and `config.file` are not provided, jsdom will load HTML from this URL.
- `config.scripts`: see `scripts` above.
- `config.src`: an array of JavaScript strings that will be evaluated against the resulting document. Similar to `scripts`, but it accepts JavaScript instead of paths/URLs.
- `config.cookieJar`: cookie jar which will be used by document and related resource requests. Can be created by `jsdom.createCookieJar()` method. Useful to share cookie state among different documents as browsers does.
- `config.parsingMode`: either `"auto"`, `"html"`, or `"xml"`. The default is `"auto"`, which uses HTML behavior unless `config.url` responds with an XML `Content-Type`, or `config.file` contains a filename ending in `.xml` or `.xhtml`. Setting to `"xml"` will attempt to parse the document as an XHTML document. (jsdom is [currently only OK at doing that](https://github.com/tmpvar/jsdom/labels/x%28ht%29ml).)
- `config.referrer`: the new document will have this referrer.
- `config.cookie`: manually set a cookie value, e.g. `'key=value; expires=Wed, Sep 21 2011 12:00:00 GMT; path=/'`. Accepts cookie string or array of cookie strings.
- `config.headers`: an object giving any headers that will be used while loading the HTML from `config.url`, if applicable.
- `config.userAgent`: the user agent string used in requests; defaults to `Node.js (#process.platform#; U; rv:#process.version#)`
- `config.features`: see Flexibility section below. **Note**: the default feature set for `jsdom.env` does _not_ include fetching remote JavaScript and executing it. This is something that you will need to _carefully_ enable yourself.
- `config.resourceLoader`: a function that intercepts subresource requests and allows you to re-route them, modify, or outright replace them with your own content. More below.
- `config.done`, `config.onload`, `config.created`: see below.
- `config.concurrentNodeIterators`: the maximum amount of `NodeIterator`s that you can use at the same time. The default is `10`; setting this to a high value will hurt performance.
- `config.virtualConsole`: a virtual console instance that can capture the windows console output; see the "Capturing Console Output" examples.
- `config.pool`: an object describing which agents to use for the requests; defaults to `{ maxSockets: 6 }`, see [request module](https://github.com/request/request#requestoptions-callback) for more details.
- `config.agent`: `http(s).Agent` instance to use
- `config.agentClass`: alternatively specify your agent's class name
- `config.agentOptions`: the agent options; defaults to `{ keepAlive: true, keepAliveMsecs: 115000 }`, see [http api](https://nodejs.org/api/http.html) for more details.
- `config.strictSSL`: if `true`, requires SSL certificates be valid; defaults to `true`, see [request module](https://github.com/request/request#requestoptions-callback) for more details.
- `config.proxy`: a URL for a HTTP proxy to use for the requests.
Note that at least one of the callbacks (`done`, `onload`, or `created`) is required, as is one of `html`, `file`, or `url`.
### Initialization lifecycle
If you just want to load the document and execute it, the `done` callback shown above is the simplest. If anything goes wrong while loading the document and creating the window, the problem will show up in the `error` passed as the first argument.
However, if you want more control over or insight into the initialization lifecycle, you'll want to use the `created` and/or `onload` callbacks:
#### `created(error, window)`
The `created` callback is called as soon as the window is created, or if that process fails. You may access all `window` properties here; however, `window.document` is not ready for use yet, as the HTML has not been parsed.
The primary use-case for `created` is to modify the window object (e.g. add new functions on built-in prototypes) before any scripts execute.
You can also set an event handler for `'load'` or other events on the window if you wish.
If the `error` argument is non-`null`, it will contain whatever loading or initialization error caused the window creation to fail; in that case `window` will not be passed.
#### `onload(window)`
The `onload` callback is called along with the window's `'load'` event. This means it will only be called if creation succeeds without error. Note that by the time it has called, any external resources will have been downloaded, and any `<script>`s will have finished executing.
#### `done(error, window)`
Now that you know about `created` and `onload`, you can see that `done` is essentially both of them smashed together:
- If window creation fails, then `error` will be the creation error.
- Otherwise, `window` will be a fully-loaded window, with all external resources downloaded and `<script>`s executed.
#### Dealing with asynchronous script loading
If you load scripts asynchronously, e.g. with a module loader like RequireJS, none of the above hooks will really give you what you want. There's nothing, either in jsdom or in browsers, to say "notify me after all asynchronous loads have completed." The solution is to use the mechanisms of the framework you are using to notify about this finishing up. E.g., with RequireJS, you could do
```js
// On the Node.js side:
var window = jsdom.jsdom(...).defaultView;
window.onModulesLoaded = function () {
console.log("ready to roll!");
};
```
```html
<!-- Inside the HTML you supply to jsdom -->
<script>
requirejs(["entry-module"], function () {
window.onModulesLoaded();
});
</script>
```
For more details, see the discussion in [#640](https://github.com/tmpvar/jsdom/issues/640), especially [@matthewkastor](https://github.com/matthewkastor)'s [insightful comment](https://github.com/tmpvar/jsdom/issues/640#issuecomment-22216965).
#### Listening for script errors during initialization
Although it is easy to listen for script errors after initialization, via code like
```js
var window = jsdom.jsdom(...).defaultView;
window.addEventListener("error", function (event) {
console.error("script error!!", event.error);
});
```
it is often also desirable to listen for any script errors during initialization, or errors loading scripts passed to `jsdom.env`. To do this, use the virtual console feature, described in more detail later:
```js
var virtualConsole = jsdom.createVirtualConsole();
virtualConsole.on("jsdomError", function (error) {
console.error(error.stack, error.detail);
});
var window = jsdom.jsdom(..., { virtualConsole }).defaultView;
```
You also get this functionality for free by default if you use `virtualConsole.sendTo`; again, see more below:
```js
var virtualConsole = jsdom.createVirtualConsole().sendTo(console);
var window = jsdom.jsdom(..., { virtualConsole }).defaultView;
```
### On running scripts and being safe
By default, `jsdom.env` will not process and run external JavaScript, since our sandbox is not foolproof. That is, code running inside the DOM's `<script>`s can, if it tries hard enough, get access to the Node environment, and thus to your machine. If you want to (carefully!) enable running JavaScript, you can use `jsdom.jsdom`, `jsdom.jQueryify`, or modify the defaults passed to `jsdom.env`.
### On timers and process lifetime
Timers in the page (set by `window.setTimeout` or `window.setInterval`) will, by definition, execute code in the future in the context of the `window`. Since there is no way to execute code in the future without keeping the process alive, note that outstanding jsdom timers will keep your Node.js process alive. Similarly, since there is no way to execute code in the context of an object without keeping that object alive, outstanding jsdom timers will prevent garbage collection of the `window` on which they are scheduled. If you want to be sure to shut down a jsdom window, use `window.close()`, which will terminate all running timers (and also remove any event listeners on the `window` and `document`).
## For the hardcore: `jsdom.jsdom`
The `jsdom.jsdom` method does fewer things automatically; it takes in only HTML source, and it does not allow you to separately supply scripts that it will inject and execute. It just gives you back a `document` object, with usable `document.defaultView`, and starts asynchronously executing any `<script>`s included in the HTML source. You can listen for the `'load'` event to wait until scripts are done loading and executing, just like you would in a normal HTML page.
Usage of the API generally looks like this:
```js
var jsdom = require("jsdom").jsdom;
var doc = jsdom(markup, options);
var window = doc.defaultView;
```
- `markup` is a HTML document to be parsed. You can also pass `undefined` to get the basic document, equivalent to what a browser will give if you open up an empty `.html` file.
- `options`: see the explanation of the `config` object above.
### Flexibility
One of the goals of jsdom is to be as minimal and light as possible. This section details how someone can change the behavior of `Document`s before they are created. These features are baked into the `DOMImplementation` that every `Document` has, and may be tweaked in two ways:
1. When you create a new `Document`, by overriding the configuration:
```js
var jsdom = require("jsdom").jsdom;
var doc = jsdom("<html><body></body></html>", {
features: {
FetchExternalResources : ["link"]
}
});
```
Do note, that this will only affect the document that is currently being created. All other documents will use the defaults specified below (see: Default Features).
2. Before creating any documents, you can modify the defaults for all future documents:
```js
require("jsdom").defaultDocumentFeatures = {
FetchExternalResources: ["script"],
ProcessExternalResources: false
};
```
#### External Resources
Default features are extremely important for jsdom as they lower the configuration requirement and present developers a set of consistent default behaviors. The following sections detail the available features, their defaults, and the values that jsdom uses.
`FetchExternalResources`
- _Default_: `["script", "link"]`
- _Allowed_: `["script", "frame", "iframe", "link", "img"]` or `false`
- _Default for `jsdom.env`_: `false`
Enables/disables fetching files over the file system/HTTP
`ProcessExternalResources`
- _Default_: `["script"]`
- _Allowed_: `["script"]` or `false`
- _Default for `jsdom.env`_: `false`
Enables/disables JavaScript execution
`SkipExternalResources`
- _Default_: `false` (allow all)
- _Allowed_: `/url to be skipped/` or `false`
- _Example_: `/http:\/\/example.org/js/bad\.js/`
Filters resource downloading and processing to disallow those matching the given regular expression
#### Custom External Resource Loader
jsdom lets you intercept subresource requests using `config.resourceLoader`. `config.resourceLoader` expects a function which is called for each subresource request with the following arguments:
- `resource`: a vanilla JavaScript object with the following properties
- `element`: the element that requested the resource.
- `url`: a parsed URL object.
- `cookie`: the content of the HTTP cookie header (`key=value` pairs separated by semicolons).
- `baseUrl`: the base URL used to resolve relative URLs.
- `defaultFetch(callback)`: a convenience method to fetch the resource online.
- `callback`: a function to be called with two arguments
- `error`: either `null`, if nothing goes wrong, or an `Error` object.
- `body`: a string representing the body of the resource.
For example, fetching all JS files from a different directory and running them in strict mode:
```js
var jsdom = require("jsdom");
jsdom.env({
url: "http://example.com/",
resourceLoader: function (resource, callback) {
var pathname = resource.url.pathname;
if (/\.js$/.test(pathname)) {
resource.url.pathname = pathname.replace("/js/", "/js/raw/");
return resource.defaultFetch(function (err, body) {
if (err) return callback(err);
callback(null, '"use strict";\n' + body);
});
} else {
return resource.defaultFetch(callback);
}
},
features: {
FetchExternalResources: ["script"],
ProcessExternalResources: ["script"],
SkipExternalResources: false
}
});
```
You can return an object containing an `abort()` function which will be called if the window is closed or stopped before the request ends.
The `abort()` function should stop the request and call the callback with an error.
For example, simulating a long request:
```js
var jsdom = require("jsdom");
jsdom.env({
url: "http://example.com/",
resourceLoader: function (resource, callback) {
var pathname = resource.url.pathname;
if (/\.json$/.test(pathname)) {
var timeout = setTimeout(function() {
callback(null, "{\"test\":\"test\"}");
}, 10000);
return {
abort: function() {
clearTimeout(timeout);
callback(new Error("request canceled by user"));
}
};
} else {
return resource.defaultFetch(callback);
}
},
features: {
FetchExternalResources: ["script"],
ProcessExternalResources: ["script"],
SkipExternalResources: false
}
});
```
## Canvas
jsdom includes support for using the [canvas](https://npmjs.org/package/canvas) or [canvas-prebuilt](https://npmjs.org/package/canvas-prebuilt) package to extend any `<canvas>` elements with the canvas API. To make this work, you need to include canvas as a dependency in your project, as a peer of jsdom. If jsdom can find the canvas package, it will use it, but if it's not present, then `<canvas>` elements will behave like `<div>`s.
## More Examples
### Creating a browser-like window object
```js
var jsdom = require("jsdom").jsdom;
var document = jsdom("hello world");
var window = document.defaultView;
console.log(window.document.documentElement.outerHTML);
// output: "<html><head></head><body>hello world</body></html>"
console.log(window.innerWidth);
// output: 1024
console.log(typeof window.document.getElementsByClassName);
// outputs: function
```
### jQueryify
```js
var jsdom = require("jsdom");
var window = jsdom.jsdom().defaultView;
jsdom.jQueryify(window, "http://code.jquery.com/jquery-2.1.1.js", function () {
window.$("body").append('<div class="testing">Hello World, It works</div>');
console.log(window.$(".testing").text());
});
```
### Passing objects to scripts inside the page
```js
var jsdom = require("jsdom").jsdom;
var window = jsdom().defaultView;
window.__myObject = { foo: "bar" };
var scriptEl = window.document.createElement("script");
scriptEl.src = "anotherScript.js";
window.document.body.appendChild(scriptEl);
// anotherScript.js will have the ability to read `window.__myObject`, even
// though it originated in Node.js!
```
### Shimming unimplemented APIs
```js
var jsdom = require("jsdom");
var document = jsdom("", {
created(err, window) {
window.alert = () => {
// Do something different than jsdom's default "not implemented" virtual console error
};
Object.defineProperty(window, "outerWidth", {
get() { return 400; },
enumerable: true,
configurable: true
});
}
});
```
### Serializing a document
```js
var jsdom = require("jsdom").jsdom;
var serializeDocument = require("jsdom").serializeDocument;
var doc = jsdom("<!DOCTYPE html>hello");
serializeDocument(doc) === "<!DOCTYPE html><html><head></head><body>hello</body></html>";
doc.documentElement.outerHTML === "<html><head></head><body>hello</body></html>";
```
### Sharing cookie state among pages
```js
var jsdom = require("jsdom");
var cookieJar = jsdom.createCookieJar();
jsdom.env({
url: 'http://google.com',
cookieJar: cookieJar,
done: function (err1, window1) {
//...
jsdom.env({
url: 'http://code.google.com',
cookieJar: cookieJar,
done: function (err2, window2) {
//...
}
});
}
});
```
### Capturing Console Output
#### Forward a window's console output to the Node.js console
```js
var jsdom = require("jsdom");
var document = jsdom.jsdom(undefined, {
virtualConsole: jsdom.createVirtualConsole().sendTo(console)
});
```
By default this will forward all `"jsdomError"` events to `console.error`. If you want to maintain only a strict one-to-one mapping of events to method calls, and perhaps handle `"jsdomErrors"` yourself, then you can do `sendTo(console, { omitJsdomErrors: true })`.
#### Create an event emitter for a window's console
```js
var jsdom = require("jsdom");
var virtualConsole = jsdom.createVirtualConsole();
virtualConsole.on("log", function (message) {
console.log("console.log called ->", message);
});
var document = jsdom.jsdom(undefined, {
virtualConsole: virtualConsole
});
```
Post-initialization, if you didn't pass in a `virtualConsole` or no longer have a reference to it, you can retrieve the `virtualConsole` by using:
```js
var virtualConsole = jsdom.getVirtualConsole(window);
```
#### Virtual console `jsdomError` error reporting
Besides the usual events, corresponding to `console` methods, the virtual console is also used for reporting errors from jsdom itself. This is similar to how error messages often show up in web browser consoles, even if they are not initiated by `console.error`. So far, the following errors are output this way:
- Errors loading or parsing external resources (scripts, stylesheets, frames, and iframes)
- Script execution errors that are not handled by a window `onerror` event handler that returns `true` or calls `event.preventDefault()`
- Calls to methods, like `window.alert`, which jsdom does not implement, but installs anyway for web compatibility
### Getting a node's location within the source
To find where a DOM node is within the source document, we provide the `jsdom.nodeLocation` function:
```js
var jsdom = require("jsdom");
var document = jsdom.jsdom(`<p>Hello
<img src="foo.jpg">
</p>`);
var bodyEl = document.body; // implicitly created
var pEl = document.querySelector("p");
var textNode = pEl.firstChild;
var imgEl = document.querySelector("img");
console.log(jsdom.nodeLocation(bodyEl)); // null; it's not in the source
console.log(jsdom.nodeLocation(pEl)); // { start: 0, end: 39, startTag: ..., endTag: ... }
console.log(jsdom.nodeLocation(textNode)); // { start: 3, end: 13 }
console.log(jsdom.nodeLocation(imgEl)); // { start: 13, end: 32 }
```
This returns the [parse5 location info](https://www.npmjs.com/package/parse5#options-locationinfo) for the node.
#### Overriding `window.top`
The `top` property on `window` is marked `[Unforgeable]` in the spec, meaning it is a non-configurable own property and thus cannot be overridden or shadowed by normal code running inside the jsdom window, even using `Object.defineProperty`. However, if you're acting from outside the window, e.g. in some test framework that creates jsdom instances, you can override it using the special `jsdom.reconfigureWindow` function:
```js
jsdom.reconfigureWindow(window, { top: myFakeTopForTesting });
```
In the future we may expand `reconfigureWindow` to allow overriding other `[Unforgeable]` properties. Let us know if you need this capability.
#### Changing the URL of an existing jsdom `Window` instance
At present jsdom does not handle navigation (such as setting `window.location.href === "https://example.com/"`). However, if you'd like to change the URL of an existing `Window` instance (such as for testing purposes), you can use the `jsdom.changeURL` method:
```js
jsdom.changeURL(window, "https://example.com/");
```
#### Running vm scripts
Although in most cases it's simplest to just insert a `<script>` element or call `window.eval`, in some cases you want access to the raw [vm context](https://nodejs.org/api/vm.html) underlying jsdom to run scripts. You can do that like so:
```js
const script = new vm.Script("globalVariable = 5;", { filename: "test.js" });
jsdom.evalVMScript(window, script);
```
## jsdom vs. PhantomJS
Some people wonder what the differences are between jsdom and [PhantomJS](http://phantomjs.org/), and when you would use one over the other. Here we attempt to explain some of the differences, and why we find jsdom to be a pleasure to use for testing and scraping use cases.
PhantomJS is a complete browser (although it uses a very old and rare rendering engine). It even performs layout and rendering, allowing you to query element positions or take a screenshot. jsdom is not a full browser: it does not perform layout or rendering, and it does not support navigation between pages. It _does_ support the DOM, HTML, canvas, many other web platform APIs, and running scripts.
So you could use jsdom to fetch the HTML of your web application (while also executing the JavaScript code within that HTML). And then you could examine and modify the resulting DOM tree. Or you could trigger event listeners to test how the web application reacts. You could also use jsdom to build up your own DOM tree from scratch, and then serialize it to a HTML string.
You need an executable to run PhantomJS. It is written in native code, and has to be compiled for each platform. jsdom is pure JavaScript, and runs wherever Node.js runs. It even has experimental support for running within browsers, giving you the ability to create a whole DOM Document inside a web worker.
One of the reasons jsdom is used a lot for testing is that creating a new document instance has very little overhead in jsdom. Opening a new page in PhantomJS takes a lot of time, so running a lot of small tests in fresh documents could take minutes in PhantomJS, but only seconds in jsdom.
Another important benefit jsdom has for testing is a bit more complicated: it is easy to suffer race conditions using an external process like PhantomJS (or Selenium). For example if you create a script to test something using PhantomJS, that script will live in a different process than the web application. If you perform multiple steps in your test that are dependent on each other (for example, step 1: find the element; step 2: click on the element), the application might change the DOM during those steps (step 1.5: the page's JavaScript removes the element). This is not an issue in jsdom, since your tests live in exactly the same thread and event loop as the web application, so if your test is executing JavaScript code, the web application cannot run its code until your test releases control of the event loop.
In general the same reasons that make jsdom pleasant for testing also make it pleasant for web scraping. In both cases, the extra power of a full browser is not as important as getting things done easily and quickly.
## What Standards Does jsdom Support, Exactly?
Our mission is to get something very close to a headless browser, with emphasis more on the DOM/HTML side of things than the CSS side. As such, our primary goals are supporting [The DOM Standard](http://dom.spec.whatwg.org/) and [The HTML Standard](http://www.whatwg.org/specs/web-apps/current-work/multipage/). We only support some subset of these so far; in particular we have the subset covered by the outdated DOM 2 spec family down pretty well. We're slowly including more and more from the modern DOM and HTML specs, including some `Node` APIs, `querySelector(All)`, attribute semantics, the history and URL APIs, and the HTML parsing algorithm.
We also support some subset of the [CSSOM](http://dev.w3.org/csswg/cssom/), largely via [@chad3814](https://github.com/chad3814)'s excellent [cssstyle](https://www.npmjs.org/package/cssstyle) package. In general we want to make webpages run headlessly as best we can, and if there are other specs we should be incorporating, let us know.
### Supported encodings
The supported encodings are the ones listed [in the Encoding Standard](https://encoding.spec.whatwg.org/#names-and-labels) excluding these:
- ISO-8859-8-I
- x-mac-cyrillic
- ISO-2022-JP
- replacement
- x-user-defined

View File

@@ -0,0 +1,461 @@
"use strict";
/* eslint-disable no-unused-expressions */
() => `jsdom 7.x onward only works on Node.js 4 or newer: https://github.com/tmpvar/jsdom#install`;
/* eslint-enable no-unused-expressions */
const fs = require("fs");
const path = require("path");
const CookieJar = require("tough-cookie").CookieJar;
const parseContentType = require("content-type-parser");
const toFileUrl = require("./jsdom/utils").toFileUrl;
const documentFeatures = require("./jsdom/browser/documentfeatures");
const domToHtml = require("./jsdom/browser/domtohtml").domToHtml;
const Window = require("./jsdom/browser/Window");
const resourceLoader = require("./jsdom/browser/resource-loader");
const VirtualConsole = require("./jsdom/virtual-console");
const locationInfo = require("./jsdom/living/helpers/internal-constants").locationInfo;
const idlUtils = require("./jsdom/living/generated/utils");
const Blob = require("./jsdom/living/generated/Blob");
const whatwgURL = require("whatwg-url");
require("./jsdom/living"); // Enable living standard features
/* eslint-disable no-restricted-modules */
// TODO: stop using the built-in URL in favor of the spec-compliant whatwg-url package
// This legacy usage is in the process of being purged.
const URL = require("url");
/* eslint-enable no-restricted-modules */
const canReadFilesFromFS = Boolean(fs.readFile); // in a browserify environment, this isn't present
exports.createVirtualConsole = function (options) {
return new VirtualConsole(options);
};
exports.getVirtualConsole = function (window) {
return window._virtualConsole;
};
exports.createCookieJar = function () {
return new CookieJar(null, { looseMode: true });
};
exports.nodeLocation = function (node) {
return idlUtils.implForWrapper(node)[locationInfo];
};
exports.reconfigureWindow = function (window, newProps) {
if ("top" in newProps) {
window._top = newProps.top;
}
};
exports.changeURL = function (window, urlString) {
const doc = idlUtils.implForWrapper(window._document);
const url = whatwgURL.parseURL(urlString);
if (url === "failure") {
throw new TypeError(`Could not parse "${urlString}" as a URL`);
}
doc._URL = url;
doc._origin = whatwgURL.serializeURLToUnicodeOrigin(doc._URL);
};
// Proxy to features module
Object.defineProperty(exports, "defaultDocumentFeatures", {
enumerable: true,
configurable: true,
get() {
return documentFeatures.defaultDocumentFeatures;
},
set(v) {
documentFeatures.defaultDocumentFeatures = v;
}
});
exports.jsdom = function (html, options) {
if (options === undefined) {
options = {};
}
if (options.parsingMode === undefined || options.parsingMode === "auto") {
options.parsingMode = "html";
}
if (options.parsingMode !== "html" && options.parsingMode !== "xml") {
throw new RangeError(`Invalid parsingMode option ${JSON.stringify(options.parsingMode)}; must be either "html", ` +
`"xml", "auto", or undefined`);
}
options.encoding = options.encoding || "UTF-8";
setGlobalDefaultConfig(options);
// Back-compat hack: we have previously suggested nesting these under document, for jsdom.env at least.
// So we need to support that.
if (options.document) {
if (options.document.cookie !== undefined) {
options.cookie = options.document.cookie;
}
if (options.document.referrer !== undefined) {
options.referrer = options.document.referrer;
}
}
// List options explicitly to be clear which are passed through
const window = new Window({
parsingMode: options.parsingMode,
contentType: options.contentType,
encoding: options.encoding,
parser: options.parser,
url: options.url,
lastModified: options.lastModified,
referrer: options.referrer,
cookieJar: options.cookieJar,
cookie: options.cookie,
resourceLoader: options.resourceLoader,
deferClose: options.deferClose,
concurrentNodeIterators: options.concurrentNodeIterators,
virtualConsole: options.virtualConsole,
pool: options.pool,
agent: options.agent,
agentClass: options.agentClass,
agentOptions: options.agentOptions,
strictSSL: options.strictSSL,
proxy: options.proxy,
userAgent: options.userAgent
});
const documentImpl = idlUtils.implForWrapper(window.document);
documentFeatures.applyDocumentFeatures(documentImpl, options.features);
if (options.created) {
options.created(null, window.document.defaultView);
}
if (options.parsingMode === "html") {
if (html === undefined || html === "") {
html = "<html><head></head><body></body></html>";
}
window.document.write(html);
} else if (options.parsingMode === "xml") {
if (html !== undefined) {
documentImpl._htmlToDom.appendHtmlToDocument(html, documentImpl);
}
}
if (window.document.close && !options.deferClose) {
window.document.close();
}
return window.document;
};
exports.jQueryify = exports.jsdom.jQueryify = function (window, jqueryUrl, callback) {
if (!window || !window.document) {
return;
}
const implImpl = idlUtils.implForWrapper(window.document.implementation);
const features = implImpl._features;
implImpl._addFeature("FetchExternalResources", ["script"]);
implImpl._addFeature("ProcessExternalResources", ["script"]);
const scriptEl = window.document.createElement("script");
scriptEl.className = "jsdom";
scriptEl.src = jqueryUrl;
scriptEl.onload = scriptEl.onerror = () => {
implImpl._features = features;
if (callback) {
callback(window, window.jQuery);
}
};
window.document.body.appendChild(scriptEl);
};
exports.env = exports.jsdom.env = function () {
const config = getConfigFromArguments(arguments);
let req = null;
if (config.file && canReadFilesFromFS) {
req = resourceLoader.readFile(config.file,
{ defaultEncoding: config.defaultEncoding, detectMetaCharset: true },
(err, text, res) => {
if (err) {
reportInitError(err, config);
return;
}
const contentType = parseContentType(res.headers["content-type"]);
config.encoding = contentType.get("charset");
setParsingModeFromExtension(config, config.file);
config.html = text;
processHTML(config);
});
} else if (config.html !== undefined) {
processHTML(config);
} else if (config.url) {
req = handleUrl(config);
} else if (config.somethingToAutodetect !== undefined) {
const url = URL.parse(config.somethingToAutodetect);
if (url.protocol && url.hostname) {
config.url = config.somethingToAutodetect;
req = handleUrl(config.somethingToAutodetect);
} else if (canReadFilesFromFS) {
req = resourceLoader.readFile(config.somethingToAutodetect,
{ defaultEncoding: config.defaultEncoding, detectMetaCharset: true },
(err, text, res) => {
if (err) {
if (err.code === "ENOENT" || err.code === "ENAMETOOLONG") {
config.html = config.somethingToAutodetect;
processHTML(config);
} else {
reportInitError(err, config);
}
} else {
const contentType = parseContentType(res.headers["content-type"]);
config.encoding = contentType.get("charset");
setParsingModeFromExtension(config, config.somethingToAutodetect);
config.html = text;
config.url = toFileUrl(config.somethingToAutodetect);
processHTML(config);
}
});
} else {
config.html = config.somethingToAutodetect;
processHTML(config);
}
}
function handleUrl() {
config.cookieJar = config.cookieJar || exports.createCookieJar();
const options = {
defaultEncoding: config.defaultEncoding,
detectMetaCharset: true,
headers: config.headers,
pool: config.pool,
strictSSL: config.strictSSL,
proxy: config.proxy,
cookieJar: config.cookieJar,
userAgent: config.userAgent,
agent: config.agent,
agentClass: config.agentClass,
agentOptions: config.agentOptions
};
const fragment = whatwgURL.parseURL(config.url).fragment;
return resourceLoader.download(config.url, options, (err, responseText, res) => {
if (err) {
reportInitError(err, config);
return;
}
// The use of `res.request.uri.href` ensures that `window.location.href`
// is updated when `request` follows redirects.
config.html = responseText;
config.url = res.request.uri.href;
if (fragment) {
config.url += `#${fragment}`;
}
if (res.headers["last-modified"]) {
config.lastModified = new Date(res.headers["last-modified"]);
}
const contentType = parseContentType(res.headers["content-type"]);
if (config.parsingMode === "auto") {
if (contentType.isXML()) {
config.parsingMode = "xml";
}
}
config.encoding = contentType.get("charset");
processHTML(config);
});
}
return req;
};
exports.serializeDocument = function (doc) {
return domToHtml([doc]);
};
exports.blobToBuffer = function (blob) {
return Blob.is(blob) && idlUtils.implForWrapper(blob)._buffer || undefined;
};
exports.evalVMScript = (window, script) => {
return script.runInContext(idlUtils.implForWrapper(window._document)._global);
};
function processHTML(config) {
const window = exports.jsdom(config.html, config).defaultView;
const implImpl = idlUtils.implForWrapper(window.document.implementation);
const features = JSON.parse(JSON.stringify(implImpl._features));
let docsLoaded = 0;
const totalDocs = config.scripts.length + config.src.length;
if (!window || !window.document) {
reportInitError(new Error("JSDOM: a window object could not be created."), config);
return;
}
function scriptComplete() {
docsLoaded++;
if (docsLoaded >= totalDocs) {
implImpl._features = features;
process.nextTick(() => {
if (config.onload) {
config.onload(window);
}
if (config.done) {
config.done(null, window);
}
});
}
}
function handleScriptError() {
// nextTick so that an exception within scriptComplete won't cause
// another script onerror (which would be an infinite loop)
process.nextTick(scriptComplete);
}
if (config.scripts.length > 0 || config.src.length > 0) {
implImpl._addFeature("FetchExternalResources", ["script"]);
implImpl._addFeature("ProcessExternalResources", ["script"]);
for (const scriptSrc of config.scripts) {
const script = window.document.createElement("script");
script.className = "jsdom";
script.onload = scriptComplete;
script.onerror = handleScriptError;
script.src = scriptSrc;
window.document.body.appendChild(script);
}
for (const scriptText of config.src) {
const script = window.document.createElement("script");
script.onload = scriptComplete;
script.onerror = handleScriptError;
script.text = scriptText;
window.document.documentElement.appendChild(script);
window.document.documentElement.removeChild(script);
}
} else if (window.document.readyState === "complete") {
scriptComplete();
} else {
window.addEventListener("load", scriptComplete);
}
}
function setGlobalDefaultConfig(config) {
config.pool = config.pool !== undefined ? config.pool : {
maxSockets: 6
};
config.agentOptions = config.agentOptions !== undefined ? config.agentOptions : {
keepAlive: true,
keepAliveMsecs: 115 * 1000
};
config.strictSSL = config.strictSSL !== undefined ? config.strictSSL : true;
config.userAgent = config.userAgent ||
`Node.js (${process.platform}; U; rv:${process.version}) AppleWebKit/537.36 (KHTML, like Gecko)`;
}
function getConfigFromArguments(args) {
const config = {};
if (typeof args[0] === "object") {
Object.assign(config, args[0]);
} else {
for (const arg of args) {
switch (typeof arg) {
case "string":
config.somethingToAutodetect = arg;
break;
case "function":
config.done = arg;
break;
case "object":
if (Array.isArray(arg)) {
config.scripts = arg;
} else {
Object.assign(config, arg);
}
break;
}
}
}
if (!config.done && !config.created && !config.onload) {
throw new Error("Must pass a \"created\", \"onload\", or \"done\" option, or a callback, to jsdom.env");
}
if (config.somethingToAutodetect === undefined &&
config.html === undefined && !config.file && !config.url) {
throw new Error("Must pass a \"html\", \"file\", or \"url\" option, or a string, to jsdom.env");
}
config.scripts = ensureArray(config.scripts);
config.src = ensureArray(config.src);
config.parsingMode = config.parsingMode || "auto";
config.features = config.features || {
FetchExternalResources: false,
ProcessExternalResources: false,
SkipExternalResources: false
};
if (!config.url && config.file) {
config.url = toFileUrl(config.file);
}
config.defaultEncoding = config.defaultEncoding || "windows-1252";
setGlobalDefaultConfig(config);
return config;
}
function reportInitError(err, config) {
if (config.created) {
config.created(err);
}
if (config.done) {
config.done(err);
}
}
function ensureArray(value) {
let array = value || [];
if (typeof array === "string") {
array = [array];
}
return array;
}
function setParsingModeFromExtension(config, filename) {
if (config.parsingMode === "auto") {
const ext = path.extname(filename);
if (ext === ".xhtml" || ext === ".xml") {
config.parsingMode = "xml";
}
}
}

View File

@@ -0,0 +1,550 @@
"use strict";
const webIDLConversions = require("webidl-conversions");
const CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
const notImplemented = require("./not-implemented");
const VirtualConsole = require("../virtual-console");
const define = require("../utils").define;
const EventTarget = require("../living/generated/EventTarget");
const namedPropertiesWindow = require("../living/named-properties-window");
const cssom = require("cssom");
const postMessage = require("../living/post-message");
const DOMException = require("../web-idl/DOMException");
const btoa = require("abab").btoa;
const atob = require("abab").atob;
const idlUtils = require("../living/generated/utils");
const createXMLHttpRequest = require("../living/xmlhttprequest");
const createFileReader = require("../living/generated/FileReader").createInterface;
const Document = require("../living/generated/Document");
const Navigator = require("../living/generated/Navigator");
const reportException = require("../living/helpers/runtime-script-errors");
// NB: the require() must be after assigning `module.exports` because this require() is circular
// TODO: this above note might not even be true anymore... figure out the cycle and document it, or clean up.
module.exports = Window;
const dom = require("../living");
const cssSelectorSplitRE = /((?:[^,"']|"[^"]*"|'[^']*')+)/;
const defaultStyleSheet = cssom.parse(require("./default-stylesheet"));
dom.Window = Window;
// NOTE: per https://heycam.github.io/webidl/#Global, all properties on the Window object must be own-properties.
// That is why we assign everything inside of the constructor, instead of using a shared prototype.
// You can verify this in e.g. Firefox or Internet Explorer, which do a good job with Web IDL compliance.
function Window(options) {
EventTarget.setup(this);
const window = this;
///// INTERFACES FROM THE DOM
// TODO: consider a mode of some sort where these are not shared between all DOM instances
// It'd be very memory-expensive in most cases, though.
for (const name in dom) {
Object.defineProperty(window, name, {
enumerable: false,
configurable: true,
writable: true,
value: dom[name]
});
}
this._core = dom;
///// PRIVATE DATA PROPERTIES
// vm initialization is defered until script processing is activated (in level1/core)
this._globalProxy = this;
this.__timers = Object.create(null);
// Set up the window as if it's a top level window.
// If it's not, then references will be corrected by frame/iframe code.
this._parent = this._top = this._globalProxy;
this._frameElement = null;
// List options explicitly to be clear which are passed through
this._document = Document.create([], {
core: dom,
options: {
parsingMode: options.parsingMode,
contentType: options.contentType,
encoding: options.encoding,
cookieJar: options.cookieJar,
parser: options.parser,
url: options.url,
lastModified: options.lastModified,
referrer: options.referrer,
cookie: options.cookie,
deferClose: options.deferClose,
resourceLoader: options.resourceLoader,
concurrentNodeIterators: options.concurrentNodeIterators,
pool: options.pool,
agent: options.agent,
agentClass: options.agentClass,
agentOptions: options.agentOptions,
strictSSL: options.strictSSL,
proxy: options.proxy,
defaultView: this._globalProxy,
global: this
}
});
// https://html.spec.whatwg.org/#session-history
this._sessionHistory = [{
document: idlUtils.implForWrapper(this._document),
url: idlUtils.implForWrapper(this._document)._URL,
stateObject: null
}];
this._currentSessionHistoryEntryIndex = 0;
// This implements window.frames.length, since window.frames returns a
// self reference to the window object. This value is incremented in the
// HTMLFrameElement init function (see: level2/html.js).
this._length = 0;
if (options.virtualConsole) {
if (options.virtualConsole instanceof VirtualConsole) {
this._virtualConsole = options.virtualConsole;
} else {
throw new TypeError(
"options.virtualConsole must be a VirtualConsole (from createVirtualConsole)");
}
} else {
this._virtualConsole = new VirtualConsole();
}
///// GETTERS
const navigator = Navigator.create([], { userAgent: options.userAgent });
define(this, {
get length() {
return window._length;
},
get window() {
return window._globalProxy;
},
get frameElement() {
return window._frameElement;
},
get frames() {
return window._globalProxy;
},
get self() {
return window._globalProxy;
},
get parent() {
return window._parent;
},
get top() {
return window._top;
},
get document() {
return window._document;
},
get location() {
return idlUtils.wrapperForImpl(idlUtils.implForWrapper(window._document)._location);
},
get history() {
return idlUtils.wrapperForImpl(idlUtils.implForWrapper(window._document)._history);
},
get navigator() {
return navigator;
}
});
namedPropertiesWindow.initializeWindow(this, dom.HTMLCollection);
///// METHODS for [ImplicitThis] hack
// See https://lists.w3.org/Archives/Public/public-script-coord/2015JanMar/0109.html
this.addEventListener = this.addEventListener.bind(this);
this.removeEventListener = this.removeEventListener.bind(this);
this.dispatchEvent = this.dispatchEvent.bind(this);
///// METHODS
let latestTimerId = 0;
this.setTimeout = function (fn, ms) {
const args = [];
for (let i = 2; i < arguments.length; ++i) {
args[i - 2] = arguments[i];
}
return startTimer(window, setTimeout, clearTimeout, ++latestTimerId, fn, ms, args);
};
this.setInterval = function (fn, ms) {
const args = [];
for (let i = 2; i < arguments.length; ++i) {
args[i - 2] = arguments[i];
}
return startTimer(window, setInterval, clearInterval, ++latestTimerId, fn, ms, args);
};
this.clearInterval = stopTimer.bind(this, window);
this.clearTimeout = stopTimer.bind(this, window);
this.__stopAllTimers = stopAllTimers.bind(this, window);
function Option(text, value, defaultSelected, selected) {
if (text === undefined) {
text = "";
}
text = webIDLConversions.DOMString(text);
if (value !== undefined) {
value = webIDLConversions.DOMString(value);
}
defaultSelected = webIDLConversions.boolean(defaultSelected);
selected = webIDLConversions.boolean(selected);
const option = window._document.createElement("option");
const impl = idlUtils.implForWrapper(option);
if (text !== "") {
impl.text = text;
}
if (value !== undefined) {
impl.setAttribute("value", value);
}
if (defaultSelected) {
impl.setAttribute("selected", "");
}
impl._selectedness = selected;
return option;
}
Object.defineProperty(Option, "prototype", {
value: this.HTMLOptionElement.prototype,
configurable: false,
enumerable: false,
writable: false
});
Object.defineProperty(window, "Option", {
value: Option,
configurable: true,
enumerable: false,
writable: true
});
function Image() {
const img = window._document.createElement("img");
const impl = idlUtils.implForWrapper(img);
if (arguments.length > 0) {
impl.setAttribute("width", String(arguments[0]));
}
if (arguments.length > 1) {
impl.setAttribute("height", String(arguments[1]));
}
return img;
}
Object.defineProperty(Image, "prototype", {
value: this.HTMLImageElement.prototype,
configurable: false,
enumerable: false,
writable: false
});
Object.defineProperty(window, "Image", {
value: Image,
configurable: true,
enumerable: false,
writable: true
});
function Audio(src) {
const audio = window._document.createElement("audio");
const impl = idlUtils.implForWrapper(audio);
impl.setAttribute("preload", "auto");
if (src !== undefined) {
impl.setAttribute("src", String(src));
}
return audio;
}
Object.defineProperty(Audio, "prototype", {
value: this.HTMLAudioElement.prototype,
configurable: false,
enumerable: false,
writable: false
});
Object.defineProperty(window, "Audio", {
value: Audio,
configurable: true,
enumerable: false,
writable: true
});
function wrapConsoleMethod(method) {
return function () {
const args = Array.prototype.slice.call(arguments);
window._virtualConsole.emit.apply(window._virtualConsole, [method].concat(args));
};
}
this.postMessage = postMessage;
this.atob = function (str) {
const result = atob(str);
if (result === null) {
throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
"The string to be decoded contains invalid characters.");
}
return result;
};
this.btoa = function (str) {
const result = btoa(str);
if (result === null) {
throw new DOMException(DOMException.INVALID_CHARACTER_ERR,
"The string to be encoded contains invalid characters.");
}
return result;
};
this.FileReader = createFileReader({
window: this
}).interface;
this.XMLHttpRequest = createXMLHttpRequest(this);
// TODO: necessary for Blob and FileReader due to different-globals weirdness; investigate how to avoid this.
this.ArrayBuffer = ArrayBuffer;
this.Int8Array = Int8Array;
this.Uint8Array = Uint8Array;
this.Uint8ClampedArray = Uint8ClampedArray;
this.Int16Array = Int16Array;
this.Uint16Array = Uint16Array;
this.Int32Array = Int32Array;
this.Uint32Array = Uint32Array;
this.Float32Array = Float32Array;
this.Float64Array = Float64Array;
this.stop = function () {
const manager = idlUtils.implForWrapper(this._document)._requestManager;
if (manager) {
manager.close();
}
};
this.close = function () {
// Recursively close child frame windows, then ourselves.
const currentWindow = this;
(function windowCleaner(windowToClean) {
for (let i = 0; i < windowToClean.length; i++) {
windowCleaner(windowToClean[i]);
}
// We"re already in our own window.close().
if (windowToClean !== currentWindow) {
windowToClean.close();
}
}(this));
// Clear out all listeners. Any in-flight or upcoming events should not get delivered.
idlUtils.implForWrapper(this)._eventListeners = Object.create(null);
if (this._document) {
if (this._document.body) {
this._document.body.innerHTML = "";
}
if (this._document.close) {
// It's especially important to clear out the listeners here because document.close() causes a "load" event to
// fire.
idlUtils.implForWrapper(this._document)._eventListeners = Object.create(null);
this._document.close();
}
const doc = idlUtils.implForWrapper(this._document);
if (doc._requestManager) {
doc._requestManager.close();
}
delete this._document;
}
stopAllTimers(currentWindow);
};
this.getComputedStyle = function (node) {
const s = node.style;
const cs = new CSSStyleDeclaration();
const forEach = Array.prototype.forEach;
function setPropertiesFromRule(rule) {
if (!rule.selectorText) {
return;
}
const selectors = rule.selectorText.split(cssSelectorSplitRE);
let matched = false;
for (const selectorText of selectors) {
if (selectorText !== "" && selectorText !== "," && !matched && matchesDontThrow(node, selectorText)) {
matched = true;
forEach.call(rule.style, property => {
cs.setProperty(property, rule.style.getPropertyValue(property), rule.style.getPropertyPriority(property));
});
}
}
}
function readStylesFromStyleSheet(sheet) {
forEach.call(sheet.cssRules, rule => {
if (rule.media) {
if (Array.prototype.indexOf.call(rule.media, "screen") !== -1) {
forEach.call(rule.cssRules, setPropertiesFromRule);
}
} else {
setPropertiesFromRule(rule);
}
});
}
readStylesFromStyleSheet(defaultStyleSheet);
forEach.call(node.ownerDocument.styleSheets, readStylesFromStyleSheet);
forEach.call(s, property => {
cs.setProperty(property, s.getPropertyValue(property), s.getPropertyPriority(property));
});
return cs;
};
///// PUBLIC DATA PROPERTIES (TODO: should be getters)
this.console = {
assert: wrapConsoleMethod("assert"),
clear: wrapConsoleMethod("clear"),
count: wrapConsoleMethod("count"),
debug: wrapConsoleMethod("debug"),
error: wrapConsoleMethod("error"),
group: wrapConsoleMethod("group"),
groupCollapsed: wrapConsoleMethod("groupCollapsed"),
groupEnd: wrapConsoleMethod("groupEnd"),
info: wrapConsoleMethod("info"),
log: wrapConsoleMethod("log"),
table: wrapConsoleMethod("table"),
time: wrapConsoleMethod("time"),
timeEnd: wrapConsoleMethod("timeEnd"),
trace: wrapConsoleMethod("trace"),
warn: wrapConsoleMethod("warn")
};
function notImplementedMethod(name) {
return function () {
notImplemented(name, window);
};
}
define(this, {
name: "nodejs",
innerWidth: 1024,
innerHeight: 768,
outerWidth: 1024,
outerHeight: 768,
pageXOffset: 0,
pageYOffset: 0,
screenX: 0,
screenY: 0,
screenLeft: 0,
screenTop: 0,
scrollX: 0,
scrollY: 0,
scrollTop: 0,
scrollLeft: 0,
screen: {
width: 0,
height: 0
},
alert: notImplementedMethod("window.alert"),
blur: notImplementedMethod("window.blur"),
confirm: notImplementedMethod("window.confirm"),
createPopup: notImplementedMethod("window.createPopup"),
focus: notImplementedMethod("window.focus"),
moveBy: notImplementedMethod("window.moveBy"),
moveTo: notImplementedMethod("window.moveTo"),
open: notImplementedMethod("window.open"),
print: notImplementedMethod("window.print"),
prompt: notImplementedMethod("window.prompt"),
resizeBy: notImplementedMethod("window.resizeBy"),
resizeTo: notImplementedMethod("window.resizeTo"),
scroll: notImplementedMethod("window.scroll"),
scrollBy: notImplementedMethod("window.scrollBy"),
scrollTo: notImplementedMethod("window.scrollTo"),
toString: () => {
return "[object Window]";
}
});
///// INITIALIZATION
process.nextTick(() => {
if (!window.document) {
return; // window might've been closed already
}
if (window.document.readyState === "complete") {
const ev = window.document.createEvent("HTMLEvents");
ev.initEvent("load", false, false);
window.dispatchEvent(ev);
} else {
window.document.addEventListener("load", () => {
const ev = window.document.createEvent("HTMLEvents");
ev.initEvent("load", false, false);
window.dispatchEvent(ev);
});
}
});
}
Object.setPrototypeOf(Window, EventTarget.interface);
Object.setPrototypeOf(Window.prototype, EventTarget.interface.prototype);
function matchesDontThrow(el, selector) {
try {
return el.matches(selector);
} catch (e) {
return false;
}
}
function startTimer(window, startFn, stopFn, timerId, callback, ms, args) {
if (typeof callback !== "function") {
const code = String(callback);
callback = window._globalProxy.eval.bind(window, code + `\n//# sourceURL=${window.location.href}`);
}
const oldCallback = callback;
callback = () => {
try {
oldCallback.apply(window._globalProxy, args);
} catch (e) {
reportException(window, e, window.location.href);
}
};
const res = startFn(callback, ms);
window.__timers[timerId] = [res, stopFn];
return timerId;
}
function stopTimer(window, id) {
const timer = window.__timers[id];
if (timer) {
// Need to .call() with undefined to ensure the thisArg is not timer itself
timer[1].call(undefined, timer[0]);
delete window.__timers[id];
}
}
function stopAllTimers(window) {
Object.keys(window.__timers).forEach(key => {
const timer = window.__timers[key];
// Need to .call() with undefined to ensure the thisArg is not timer itself
timer[1].call(undefined, timer[0]);
});
window.__timers = Object.create(null);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,73 @@
"use strict";
const idlUtils = require("../living/generated/utils");
// Tree traversing
exports.getFirstChild = function (node) {
return node.childNodes[0];
};
exports.getChildNodes = function (node) {
// parse5 treats template elements specially, assuming you return an array whose single item is the document fragment
const children = node._templateContents ? [node._templateContents] : [];
if (children.length === 0) {
for (let i = 0; i < node.childNodes.length; ++i) {
children.push(idlUtils.implForWrapper(node.childNodes[i]));
}
}
return children;
};
exports.getParentNode = function (node) {
return node.parentNode;
};
exports.getAttrList = function (node) {
return node.attributes;
};
// Node data
exports.getTagName = function (element) {
return element.tagName.toLowerCase();
};
exports.getNamespaceURI = function (element) {
return element.namespaceURI || "http://www.w3.org/1999/xhtml";
};
exports.getTextNodeContent = function (textNode) {
return textNode.nodeValue;
};
exports.getCommentNodeContent = function (commentNode) {
return commentNode.nodeValue;
};
exports.getDocumentTypeNodeName = function (doctypeNode) {
return doctypeNode.name;
};
exports.getDocumentTypeNodePublicId = function (doctypeNode) {
return doctypeNode.publicId || null;
};
exports.getDocumentTypeNodeSystemId = function (doctypeNode) {
return doctypeNode.systemId || null;
};
// Node types
exports.isTextNode = function (node) {
return node.nodeName === "#text";
};
exports.isCommentNode = function (node) {
return node.nodeName === "#comment";
};
exports.isDocumentTypeNode = function (node) {
return node.nodeType === 10;
};
exports.isElementNode = function (node) {
return Boolean(node.tagName);
};

View File

@@ -0,0 +1,47 @@
"use strict";
exports.availableDocumentFeatures = [
"FetchExternalResources",
"ProcessExternalResources",
"SkipExternalResources"
];
exports.defaultDocumentFeatures = {
FetchExternalResources: ["script", "link"], // omitted by default: "frame"
ProcessExternalResources: ["script"], // omitted by default: "frame", "iframe"
SkipExternalResources: false
};
exports.applyDocumentFeatures = (documentImpl, features) => {
features = features || {};
for (let i = 0; i < exports.availableDocumentFeatures.length; ++i) {
const featureName = exports.availableDocumentFeatures[i];
let featureSource;
if (features[featureName] !== undefined) {
featureSource = features[featureName];
// We have to check the lowercase version also because the Document feature
// methods convert everything to lowercase.
} else if (typeof features[featureName.toLowerCase()] !== "undefined") {
featureSource = features[featureName.toLowerCase()];
} else if (exports.defaultDocumentFeatures[featureName]) {
featureSource = exports.defaultDocumentFeatures[featureName];
} else {
continue;
}
const implImpl = documentImpl._implementation;
implImpl._removeFeature(featureName);
if (featureSource !== undefined) {
if (Array.isArray(featureSource)) {
for (let j = 0; j < featureSource.length; ++j) {
implImpl._addFeature(featureName, featureSource[j]);
}
} else {
implImpl._addFeature(featureName, featureSource);
}
}
}
};

View File

@@ -0,0 +1,19 @@
"use strict";
const parse5 = require("parse5");
const documentAdapter = require("./documentAdapter");
const NODE_TYPE = require("../living/node-type");
const idlUtils = require("../living/generated/utils");
const serializer = new parse5.TreeSerializer(documentAdapter);
exports.domToHtml = function (iterable) {
let ret = "";
for (const node of iterable) {
if (node.nodeType === NODE_TYPE.DOCUMENT_NODE) {
ret += serializer.serialize(node);
} else {
ret += serializer.serialize({ childNodes: [idlUtils.wrapperForImpl(node)] });
}
}
return ret;
};

View File

@@ -0,0 +1,323 @@
"use strict";
const parse5 = require("parse5");
const sax = require("sax");
const attributes = require("../living/attributes");
const DocumentType = require("../living/generated/DocumentType");
const locationInfo = require("../living/helpers/internal-constants").locationInfo;
class HtmlToDom {
constructor(core, parser, parsingMode) {
if (!parser) {
if (parsingMode === "xml") {
parser = sax;
} else {
parser = parse5;
}
}
this.core = core;
this.parser = parser;
this.parsingMode = parsingMode;
if (parser.DefaultHandler) {
this.parserType = "htmlparser2";
} else if (parser.Parser && parser.TreeAdapters) {
this.parserType = "parse5v1";
} else if (parser.moduleName === "HTML5") {
this.parserType = "html5";
} else if (parser.parser) {
this.parserType = "sax";
}
}
appendHtmlToElement(html, element) {
if (typeof html !== "string") {
html = String(html);
}
return this["_parseWith" + this.parserType](html, true, element);
}
appendHtmlToDocument(html, element) {
if (typeof html !== "string") {
html = String(html);
}
return this["_parseWith" + this.parserType](html, false, element);
}
_parseWithhtmlparser2(html, fragment, element) {
const handler = new this.parser.DefaultHandler();
// Check if document is XML
const isXML = this.parsingMode === "xml";
const parserInstance = new this.parser.Parser(handler, {
xmlMode: isXML,
lowerCaseTags: !isXML,
lowerCaseAttributeNames: !isXML,
decodeEntities: true
});
parserInstance.includeLocation = false;
parserInstance.parseComplete(html);
const parsed = handler.dom;
for (let i = 0; i < parsed.length; i++) {
setChild(this.core, element, parsed[i]);
}
return element;
}
_parseWithparse5v1(html, fragment, element) {
if (this.parsingMode === "xml") {
throw new Error("Can't parse XML with parse5, please use htmlparser2 instead.");
}
const htmlparser2Adapter = this.parser.TreeAdapters.htmlparser2;
let dom;
if (fragment) {
const instance = new this.parser.Parser(htmlparser2Adapter);
const parentElement = htmlparser2Adapter.createElement(element.tagName.toLowerCase(), element.namespaceURI, []);
dom = instance.parseFragment(html, parentElement);
} else {
const instance = new this.parser.Parser(htmlparser2Adapter, { locationInfo: true });
dom = instance.parse(html);
}
const parsed = dom.children;
for (let i = 0; i < parsed.length; i++) {
setChild(this.core, element, parsed[i]);
}
return element;
}
_parseWithhtml5(html, fragment, element) {
if (element.nodeType === 9) {
new this.parser.Parser({ document: element }).parse(html);
} else {
const p = new this.parser.Parser({ document: element.ownerDocument });
p.parse_fragment(html, element);
}
}
_parseWithsax(html, fragment, element) {
const SaxParser = this.parser.parser;
const parser = new SaxParser(/* strict = */true, { xmlns: true });
parser.noscript = false;
parser.looseCase = "toString";
const openStack = [element];
parser.ontext = text => {
setChild(this.core, openStack[openStack.length - 1], {
type: "text",
data: text
});
};
parser.onopentag = arg => {
const attrValues = {};
const attrPrefixes = {};
const attrNamespaces = {};
Object.keys(arg.attributes).forEach(key => {
const localName = arg.attributes[key].local;
attrValues[localName] = arg.attributes[key].value;
attrPrefixes[localName] = arg.attributes[key].prefix || null;
attrNamespaces[localName] = arg.attributes[key].uri || null;
});
if (arg.local === "script" && arg.uri === "http://www.w3.org/1999/xhtml") {
openStack.push({
type: "tag",
name: arg.local,
prefix: arg.prefix,
namespace: arg.uri,
attribs: attrValues,
"x-attribsPrefix": attrPrefixes,
"x-attribsNamespace": attrNamespaces
});
} else {
const elem = setChild(this.core, openStack[openStack.length - 1], {
type: "tag",
name: arg.local,
prefix: arg.prefix,
namespace: arg.uri,
attribs: attrValues,
"x-attribsPrefix": attrPrefixes,
"x-attribsNamespace": attrNamespaces
});
openStack.push(elem);
}
};
parser.onclosetag = () => {
const elem = openStack.pop();
if (elem.constructor.name === "Object") { // we have an empty script tag
setChild(this.core, openStack[openStack.length - 1], elem);
}
};
parser.onscript = scriptText => {
const tag = openStack.pop();
tag.children = [{ type: "text", data: scriptText }];
const elem = setChild(this.core, openStack[openStack.length - 1], tag);
openStack.push(elem);
};
parser.oncomment = comment => {
setChild(this.core, openStack[openStack.length - 1], {
type: "comment",
data: comment
});
};
parser.onprocessinginstruction = pi => {
setChild(this.core, openStack[openStack.length - 1], {
type: "directive",
name: "?" + pi.name,
data: "?" + pi.name + " " + pi.body + "?"
});
};
parser.ondoctype = dt => {
setChild(this.core, openStack[openStack.length - 1], {
type: "directive",
name: "!doctype",
data: "!doctype " + dt
});
const entityMatcher = /<!ENTITY ([^ ]+) "([^"]+)">/g;
let result;
while ((result = entityMatcher.exec(dt))) {
// TODO Node v6 const [, name, value] = result;
const name = result[1];
const value = result[2];
if (!(name in parser.ENTITIES)) {
parser.ENTITIES[name] = value;
}
}
};
parser.onerror = err => {
throw err;
};
parser.write(html).close();
}
}
// utility function for forgiving parser
function setChild(core, parentImpl, node) {
const currentDocument = parentImpl && parentImpl._ownerDocument || parentImpl;
let newNode;
let isTemplateContents = false;
switch (node.type) {
case "tag":
case "script":
case "style":
newNode = currentDocument._createElementWithCorrectElementInterface(node.name, node.namespace);
newNode._prefix = node.prefix || null;
newNode._namespaceURI = node.namespace || null;
break;
case "root":
// If we are in <template> then add all children to the parent's _templateContents; skip this virtual root node.
if (parentImpl.tagName === "TEMPLATE" && parentImpl._namespaceURI === "http://www.w3.org/1999/xhtml") {
newNode = parentImpl._templateContents;
isTemplateContents = true;
}
break;
case "text":
// HTML entities should already be decoded by the parser, so no need to decode them
newNode = currentDocument.createTextNode(node.data);
break;
case "comment":
newNode = currentDocument.createComment(node.data);
break;
case "directive":
if (node.name[0] === "?" && node.name.toLowerCase() !== "?xml") {
const data = node.data.slice(node.name.length + 1, -1);
newNode = currentDocument.createProcessingInstruction(node.name.substring(1), data);
} else if (node.name.toLowerCase() === "!doctype") {
if (node["x-name"] !== undefined) { // parse5 supports doctypes directly
newNode = createDocumentTypeInternal(core, currentDocument,
node["x-name"] || "",
node["x-publicId"] || "",
node["x-systemId"] || "");
} else {
newNode = parseDocType(core, currentDocument, "<" + node.data + ">");
}
}
break;
}
if (!newNode) {
return null;
}
newNode[locationInfo] = node.__location;
if (node.attribs) {
Object.keys(node.attribs).forEach(localName => {
const value = node.attribs[localName];
let prefix =
node["x-attribsPrefix"] &&
Object.prototype.hasOwnProperty.call(node["x-attribsPrefix"], localName) &&
node["x-attribsPrefix"][localName] || null;
const namespace =
node["x-attribsNamespace"] &&
Object.prototype.hasOwnProperty.call(node["x-attribsNamespace"], localName) &&
node["x-attribsNamespace"][localName] || null;
if (prefix === "xmlns" && localName === "") {
// intended weirdness in node-sax, see https://github.com/isaacs/sax-js/issues/165
localName = prefix;
prefix = null;
}
attributes.setAttributeValue(newNode, localName, value, prefix, namespace);
});
}
if (node.children) {
for (let c = 0; c < node.children.length; c++) {
setChild(core, newNode, node.children[c]);
}
}
if (!isTemplateContents) {
if (parentImpl._templateContents) {
// Setting innerHTML on a <template>
parentImpl._templateContents.appendChild(newNode);
} else {
parentImpl.appendChild(newNode);
}
}
return newNode;
}
const HTML5_DOCTYPE = /<!doctype html>/i;
const PUBLIC_DOCTYPE = /<!doctype\s+([^\s]+)\s+public\s+"([^"]+)"\s+"([^"]+)"/i;
const SYSTEM_DOCTYPE = /<!doctype\s+([^\s]+)\s+system\s+"([^"]+)"/i;
function parseDocType(core, doc, html) {
if (HTML5_DOCTYPE.test(html)) {
return createDocumentTypeInternal(core, doc, "html", "", "");
}
const publicPieces = PUBLIC_DOCTYPE.exec(html);
if (publicPieces) {
return createDocumentTypeInternal(core, doc, publicPieces[1], publicPieces[2], publicPieces[3]);
}
const systemPieces = SYSTEM_DOCTYPE.exec(html);
if (systemPieces) {
return createDocumentTypeInternal(core, doc, systemPieces[1], "", systemPieces[2]);
}
// Shouldn't get here (the parser shouldn't let us know about invalid doctypes), but our logic likely isn't
// real-world perfect, so let's fallback.
return createDocumentTypeInternal(core, doc, "html", "", "");
}
function createDocumentTypeInternal(core, ownerDocument, name, publicId, systemId) {
return DocumentType.createImpl([], { core, ownerDocument, name, publicId, systemId });
}
exports.HtmlToDom = HtmlToDom;

View File

@@ -0,0 +1,13 @@
"use strict";
module.exports = function (nameForErrorMessage, window) {
if (!window) {
// Do nothing for window-less documents.
return;
}
const error = new Error(`Not implemented: ${nameForErrorMessage}`);
error.type = "not implemented";
window._virtualConsole.emit("jsdomError", error);
};

View File

@@ -0,0 +1,275 @@
"use strict";
const parseContentType = require("content-type-parser");
const sniffHTMLEncoding = require("html-encoding-sniffer");
const whatwgEncoding = require("whatwg-encoding");
const parseDataUrl = require("../utils").parseDataUrl;
const fs = require("fs");
const request = require("request");
const documentBaseURLSerialized = require("../living/helpers/document-base-url").documentBaseURLSerialized;
const NODE_TYPE = require("../living/node-type");
/* eslint-disable no-restricted-modules */
// TODO: stop using the built-in URL in favor of the spec-compliant whatwg-url package
// This legacy usage is in the process of being purged.
const URL = require("url");
/* eslint-enable no-restricted-modules */
const IS_BROWSER = Object.prototype.toString.call(process) !== "[object process]";
function createResourceLoadHandler(element, resourceUrl, document, loadCallback) {
if (loadCallback === undefined) {
loadCallback = () => {
// do nothing
};
}
return (err, data, response) => {
const ev = document.createEvent("HTMLEvents");
if (!err) {
try {
loadCallback.call(element, data, resourceUrl, response);
ev.initEvent("load", false, false);
} catch (e) {
err = e;
}
}
if (err) {
if (!err.isAbortError) {
ev.initEvent("error", false, false);
ev.error = err;
element.dispatchEvent(ev);
const error = new Error(`Could not load ${element.localName}: "${resourceUrl}"`);
error.detail = err;
error.type = "resource loading";
document._defaultView._virtualConsole.emit("jsdomError", error);
}
} else {
element.dispatchEvent(ev);
}
};
}
exports.readFile = function (filePath, options, callback) {
const readableStream = fs.createReadStream(filePath);
let data = new Buffer(0);
readableStream.on("error", callback);
readableStream.on("data", chunk => {
data = Buffer.concat([data, chunk]);
});
const defaultEncoding = options.defaultEncoding;
const detectMetaCharset = options.detectMetaCharset;
readableStream.on("end", () => {
// Not passing default encoding means binary
if (defaultEncoding) {
const encoding = detectMetaCharset ? sniffHTMLEncoding(data, { defaultEncoding }) :
whatwgEncoding.getBOMEncoding(data) || defaultEncoding;
const decoded = whatwgEncoding.decode(data, encoding);
callback(null, decoded, { headers: { "content-type": "text/plain;charset=" + encoding } });
} else {
callback(null, data);
}
});
return {
abort() {
readableStream.destroy();
const error = new Error("request canceled by user");
error.isAbortError = true;
callback(error);
}
};
};
function readDataUrl(dataUrl, options, callback) {
const defaultEncoding = options.defaultEncoding;
try {
const data = parseDataUrl(dataUrl);
// If default encoding does not exist, pass on binary data.
if (defaultEncoding) {
const contentType = parseContentType(data.type) || parseContentType("text/plain");
const sniffOptions = {
transportLayerEncodingLabel: contentType.get("charset"),
defaultEncoding
};
const encoding = options.detectMetaCharset ? sniffHTMLEncoding(data.buffer, sniffOptions) :
whatwgEncoding.getBOMEncoding(data.buffer) ||
whatwgEncoding.labelToName(contentType.get("charset")) || defaultEncoding;
const decoded = whatwgEncoding.decode(data.buffer, encoding);
contentType.set("charset", encoding);
data.type = contentType.toString();
callback(null, decoded, { headers: { "content-type": data.type } });
} else {
callback(null, data.buffer, { headers: { "content-type": data.type } });
}
} catch (err) {
callback(err, null);
}
return null;
}
// NOTE: request wraps tough-cookie cookie jar
// (see: https://github.com/request/request/blob/master/lib/cookies.js).
// Therefore, to pass our cookie jar to the request, we need to create
// request's wrapper and monkey patch it with our jar.
function wrapCookieJarForRequest(cookieJar) {
const jarWrapper = request.jar();
jarWrapper._jar = cookieJar;
return jarWrapper;
}
function fetch(urlObj, options, callback) {
if (urlObj.protocol === "data:") {
return readDataUrl(urlObj.href, options, callback);
} else if (urlObj.hostname) {
return exports.download(urlObj, options, callback);
}
const filePath = urlObj.pathname
.replace(/^file:\/\//, "")
.replace(/^\/([a-z]):\//i, "$1:/")
.replace(/%20/g, " ");
return exports.readFile(filePath, options, callback);
}
exports.enqueue = function (element, resourceUrl, callback) {
const document = element.nodeType === NODE_TYPE.DOCUMENT_NODE ? element : element._ownerDocument;
if (document._queue) {
const loadHandler = createResourceLoadHandler(element, resourceUrl || document.URL, document, callback);
return document._queue.push(loadHandler);
}
return () => {
// do nothing in queue-less documents
};
};
exports.download = function (url, options, callback) {
const requestOptions = {
pool: options.pool,
agent: options.agent,
agentOptions: options.agentOptions,
agentClass: options.agentClass,
strictSSL: options.strictSSL,
gzip: true,
jar: wrapCookieJarForRequest(options.cookieJar),
encoding: null,
headers: {
"User-Agent": options.userAgent,
"Accept-Language": "en",
Accept: options.accept || "*/*"
}
};
if (options.referrer && !IS_BROWSER) {
requestOptions.headers.referer = options.referrer;
}
if (options.proxy) {
requestOptions.proxy = options.proxy;
}
Object.assign(requestOptions.headers, options.headers);
const defaultEncoding = options.defaultEncoding;
const detectMetaCharset = options.detectMetaCharset;
const req = request(url, requestOptions, (error, response, bufferData) => {
if (!error) {
// If default encoding does not exist, pass on binary data.
if (defaultEncoding) {
const contentType = parseContentType(response.headers["content-type"]) || parseContentType("text/plain");
const sniffOptions = {
transportLayerEncodingLabel: contentType.get("charset"),
defaultEncoding
};
const encoding = detectMetaCharset ? sniffHTMLEncoding(bufferData, sniffOptions) :
whatwgEncoding.getBOMEncoding(bufferData) ||
whatwgEncoding.labelToName(contentType.get("charset")) || defaultEncoding;
const decoded = whatwgEncoding.decode(bufferData, encoding);
contentType.set("charset", encoding);
response.headers["content-type"] = contentType.toString();
callback(null, decoded, response);
} else {
callback(null, bufferData, response);
}
} else {
callback(error, null, response);
}
});
return {
abort() {
req.abort();
const error = new Error("request canceled by user");
error.isAbortError = true;
callback(error);
}
};
};
exports.load = function (element, urlString, options, callback) {
const document = element._ownerDocument;
const documentImpl = document.implementation;
if (!documentImpl._hasFeature("FetchExternalResources", element.tagName.toLowerCase())) {
return;
}
if (documentImpl._hasFeature("SkipExternalResources", urlString)) {
return;
}
const urlObj = URL.parse(urlString);
const enqueued = exports.enqueue(element, urlString, callback);
const customLoader = document._customResourceLoader;
const requestManager = document._requestManager;
const cookieJar = document._cookieJar;
options.accept = element._accept;
options.cookieJar = cookieJar;
options.referrer = document.URL;
options.pool = document._pool;
options.agentOptions = document._agentOptions;
options.strictSSL = document._strictSSL;
options.proxy = document._proxy;
options.userAgent = document._defaultView.navigator.userAgent;
let req = null;
function wrappedEnqueued() {
if (req && requestManager) {
requestManager.remove(req);
}
// do not trigger if the window is closed
if (element._ownerDocument && element._ownerDocument.defaultView.document) {
enqueued.apply(this, arguments);
}
}
if (typeof customLoader === "function") {
req = customLoader({
element,
url: urlObj,
cookie: cookieJar.getCookieStringSync(urlObj, { http: true }),
baseUrl: documentBaseURLSerialized(document),
defaultFetch(fetchCallback) {
return fetch(urlObj, options, fetchCallback);
}
},
wrappedEnqueued);
} else {
req = fetch(urlObj, options, wrappedEnqueued);
}
if (req && requestManager) {
requestManager.add(req);
}
};

View File

@@ -0,0 +1,69 @@
"use strict";
const cssom = require("cssom");
const cssstyle = require("cssstyle");
module.exports = core => {
// What works now:
// - Accessing the rules defined in individual stylesheets
// - Modifications to style content attribute are reflected in style property
// - Modifications to style property are reflected in style content attribute
// TODO
// - Modifications to style element's textContent are reflected in sheet property.
// - Modifications to style element's sheet property are reflected in textContent.
// - Modifications to link.href property are reflected in sheet property.
// - Less-used features of link: disabled
// - Less-used features of style: disabled, scoped, title
// - CSSOM-View
// - getComputedStyle(): requires default stylesheet, cascading, inheritance,
// filtering by @media (screen? print?), layout for widths/heights
// - Load events are not in the specs, but apparently some browsers
// implement something. Should onload only fire after all @imports have been
// loaded, or only the primary sheet?
core.StyleSheet = cssom.StyleSheet;
core.MediaList = cssom.MediaList;
core.CSSStyleSheet = cssom.CSSStyleSheet;
core.CSSRule = cssom.CSSRule;
core.CSSStyleRule = cssom.CSSStyleRule;
core.CSSMediaRule = cssom.CSSMediaRule;
core.CSSImportRule = cssom.CSSImportRule;
core.CSSStyleDeclaration = cssstyle.CSSStyleDeclaration;
// Relavant specs
// http://www.w3.org/TR/DOM-Level-2-Style (2000)
// http://www.w3.org/TR/cssom-view/ (2008)
// http://dev.w3.org/csswg/cssom/ (2010) Meant to replace DOM Level 2 Style
// http://www.whatwg.org/specs/web-apps/current-work/multipage/ HTML5, of course
// http://dev.w3.org/csswg/css-style-attr/ not sure what's new here
// Objects that aren't in cssom library but should be:
// CSSRuleList (cssom just uses array)
// CSSFontFaceRule
// CSSPageRule
// These rules don't really make sense to implement, so CSSOM draft makes them
// obsolete.
// CSSCharsetRule
// CSSUnknownRule
// These objects are considered obsolete by CSSOM draft, although modern
// browsers implement them.
// CSSValue
// CSSPrimitiveValue
// CSSValueList
// RGBColor
// Rect
// Counter
// http://dev.w3.org/csswg/cssom/#stylesheetlist
function StyleSheetList() {}
StyleSheetList.prototype.__proto__ = Array.prototype;
StyleSheetList.prototype.item = function item(i) {
return Object.prototype.hasOwnProperty.call(this, i) ? this[i] : null;
};
core.StyleSheetList = StyleSheetList;
};

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,468 @@
"use strict";
const DOMException = require("../web-idl/DOMException");
const defineGetter = require("../utils").defineGetter;
const idlUtils = require("./generated/utils");
const attrGenerated = require("./generated/Attr");
const changeAttributeImpl = require("./attributes/Attr-impl").changeAttributeImpl;
const getAttrImplQualifiedName = require("./attributes/Attr-impl").getAttrImplQualifiedName;
// https://dom.spec.whatwg.org/#namednodemap
const INTERNAL = Symbol("NamedNodeMap internal");
// TODO: use NamedPropertyTracker when https://github.com/tmpvar/jsdom/pull/1116 lands?
// Don't emulate named getters for these properties.
// Compiled later after NamedNodeMap is all set up.
const reservedNames = new Set();
function NamedNodeMap() {
throw new TypeError("Illegal constructor");
}
defineGetter(NamedNodeMap.prototype, "length", function () {
return this[INTERNAL].attributeList.length;
});
NamedNodeMap.prototype.item = function (index) {
if (arguments.length < 1) {
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.item");
}
// Don't bother with full unsigned long long conversion. When we have better WebIDL support generally, revisit.
index = Number(index);
return this[index] || null;
};
NamedNodeMap.prototype.getNamedItem = function (name) {
if (arguments.length < 1) {
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.getNamedItem");
}
name = String(name);
return idlUtils.wrapperForImpl(exports.getAttributeByName(this[INTERNAL].element, name));
};
NamedNodeMap.prototype.getNamedItemNS = function (namespace, localName) {
if (arguments.length < 2) {
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.getNamedItemNS");
}
if (namespace === undefined || namespace === null) {
namespace = null;
} else {
namespace = String(namespace);
}
localName = String(localName);
return idlUtils.wrapperForImpl(exports.getAttributeByNameNS(this[INTERNAL].element, namespace, localName));
};
NamedNodeMap.prototype.setNamedItem = function (attr) {
if (!attrGenerated.is(attr)) {
throw new TypeError("First argument to NamedNodeMap.prototype.setNamedItem must be an Attr");
}
return idlUtils.wrapperForImpl(exports.setAttribute(this[INTERNAL].element, idlUtils.implForWrapper(attr)));
};
NamedNodeMap.prototype.setNamedItemNS = function (attr) {
if (!attrGenerated.is(attr)) {
throw new TypeError("First argument to NamedNodeMap.prototype.setNamedItemNS must be an Attr");
}
return idlUtils.wrapperForImpl(exports.setAttribute(this[INTERNAL].element, idlUtils.implForWrapper(attr)));
};
NamedNodeMap.prototype.removeNamedItem = function (name) {
if (arguments.length < 1) {
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.getNamedItem");
}
name = String(name);
const attr = exports.removeAttributeByName(this[INTERNAL].element, name);
if (attr === null) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to remove an attribute that was not present");
}
return idlUtils.wrapperForImpl(attr);
};
NamedNodeMap.prototype.removeNamedItemNS = function (namespace, localName) {
if (arguments.length < 2) {
throw new TypeError("Not enough arguments to NamedNodeMap.prototype.removeNamedItemNS");
}
if (namespace === undefined || namespace === null) {
namespace = null;
} else {
namespace = String(namespace);
}
localName = String(localName);
const attr = exports.removeAttributeByNameNS(this[INTERNAL].element, namespace, localName);
if (attr === null) {
throw new DOMException(DOMException.NOT_FOUND_ERR, "Tried to remove an attribute that was not present");
}
return idlUtils.wrapperForImpl(attr);
};
exports.NamedNodeMap = NamedNodeMap;
{
let prototype = NamedNodeMap.prototype;
while (prototype) {
for (const name of Object.getOwnPropertyNames(prototype)) {
reservedNames.add(name);
}
prototype = Object.getPrototypeOf(prototype);
}
}
exports.createNamedNodeMap = function (element) {
const nnm = Object.create(NamedNodeMap.prototype);
nnm[INTERNAL] = {
element,
attributeList: [],
attributesByNameMap: new Map()
};
return nnm;
};
// The following three are for https://dom.spec.whatwg.org/#concept-element-attribute-has. We don't just have a
// predicate tester since removing that kind of flexibility gives us the potential for better future optimizations.
exports.hasAttribute = function (element, A) {
const attributesNNM = element._attributes;
const attributeList = attributesNNM[INTERNAL].attributeList;
return attributeList.indexOf(A) !== -1;
};
exports.hasAttributeByName = function (element, name) {
const attributesNNM = element._attributes;
const attributesByNameMap = attributesNNM[INTERNAL].attributesByNameMap;
return attributesByNameMap.has(name);
};
exports.hasAttributeByNameNS = function (element, namespace, localName) {
const attributesNNM = element._attributes;
const attributeList = attributesNNM[INTERNAL].attributeList;
return attributeList.some(attribute => {
return attribute._localName === localName && attribute._namespace === namespace;
});
};
exports.changeAttribute = function (element, attribute, value) {
// https://dom.spec.whatwg.org/#concept-element-attributes-change
// The partitioning here works around a particularly bad circular require problem. See
// https://github.com/tmpvar/jsdom/pull/1247#issuecomment-149060470
changeAttributeImpl(element, attribute, value);
};
exports.appendAttribute = function (element, attribute) {
// https://dom.spec.whatwg.org/#concept-element-attributes-append
const attributesNNM = element._attributes;
const attributeList = attributesNNM[INTERNAL].attributeList;
// TODO mutation observer stuff
attributeList.push(attribute);
attribute._element = element;
// Sync target indexed properties
attributesNNM[attributeList.length - 1] = idlUtils.wrapperForImpl(attribute);
const name = getAttrImplQualifiedName(attribute);
// Sync target named properties
if (!reservedNames.has(name) && shouldNameBeInNNMProps(element, name)) {
Object.defineProperty(attributesNNM, name, {
configurable: true,
writable: true,
enumerable: false,
value: idlUtils.wrapperForImpl(attribute)
});
}
// Sync name cache
const cache = attributesNNM[INTERNAL].attributesByNameMap;
let entry = cache.get(name);
if (!entry) {
entry = [];
cache.set(name, entry);
}
entry.push(attribute);
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is added."
element._attrModified(name, attribute._value, null);
};
exports.removeAttribute = function (element, attribute) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove
const attributesNNM = element._attributes;
const attributeList = attributesNNM[INTERNAL].attributeList;
// TODO mutation observer stuff
for (let i = 0; i < attributeList.length; ++i) {
if (attributeList[i] === attribute) {
attributeList.splice(i, 1);
attribute._element = null;
// Sync target indexed properties
for (let j = i; j < attributeList.length; ++j) {
attributesNNM[j] = idlUtils.wrapperForImpl(attributeList[j]);
}
delete attributesNNM[attributeList.length];
const name = getAttrImplQualifiedName(attribute);
// Sync target named properties
if (!reservedNames.has(name) && shouldNameBeInNNMProps(element, name)) {
delete attributesNNM[name];
}
// Sync name cache
const cache = attributesNNM[INTERNAL].attributesByNameMap;
const entry = cache.get(name);
entry.splice(entry.indexOf(attribute), 1);
if (entry.length === 0) {
cache.delete(name);
}
// Run jsdom hooks; roughly correspond to spec's "An attribute is removed."
element._attrModified(name, null, attribute._value);
return;
}
}
};
exports.replaceAttribute = function (element, oldAttr, newAttr) {
// https://dom.spec.whatwg.org/#concept-element-attributes-replace
const attributesNNM = element._attributes;
const attributeList = attributesNNM[INTERNAL].attributeList;
// TODO mutation observer stuff
for (let i = 0; i < attributeList.length; ++i) {
if (attributeList[i] === oldAttr) {
attributeList.splice(i, 1, newAttr);
oldAttr._element = null;
newAttr._element = element;
// Sync target indexed properties
attributesNNM[i] = idlUtils.wrapperForImpl(newAttr);
const name = getAttrImplQualifiedName(newAttr);
// Sync target named properties
if (!reservedNames.has(name) && shouldNameBeInNNMProps(element, name)) {
attributesNNM[name] = newAttr;
}
// Sync name cache
const cache = attributesNNM[INTERNAL].attributesByNameMap;
let entry = cache.get(name);
if (!entry) {
entry = [];
cache.set(name, entry);
}
entry.splice(entry.indexOf(oldAttr), 1, newAttr);
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed."
element._attrModified(name, newAttr._value, oldAttr._value);
return;
}
}
};
exports.getAttributeByName = function (element, name) {
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
if (element._namespaceURI === "http://www.w3.org/1999/xhtml" &&
element._ownerDocument._parsingMode === "html") {
name = name.toLowerCase();
}
const cache = element._attributes[INTERNAL].attributesByNameMap;
const entry = cache.get(name);
if (!entry) {
return null;
}
return entry[0];
};
exports.getAttributeValue = function (element, name) {
const attr = exports.getAttributeByName(element, name);
if (!attr) {
return null;
}
return attr._value;
};
exports.getAttributeByNameNS = function (element, namespace, localName) {
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace
if (namespace === "") {
namespace = null;
}
const attributeList = element._attributes[INTERNAL].attributeList;
for (let i = 0; i < attributeList.length; ++i) {
const attr = attributeList[i];
if (attr._namespace === namespace && attr._localName === localName) {
return attr;
}
}
return null;
};
exports.getAttributeValueByNameNS = function (element, namespace, localName) {
const attr = exports.getAttributeByNameNS(element, namespace, localName);
if (!attr) {
return null;
}
return attr._value;
};
exports.setAttribute = function (element, attr) {
// https://dom.spec.whatwg.org/#concept-element-attributes-set
if (attr._element !== null && attr._element !== element) {
throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR);
}
const oldAttr = exports.getAttributeByNameNS(element, attr._namespace, attr._localName);
if (oldAttr === attr) {
return attr;
}
if (oldAttr !== null) {
exports.replaceAttribute(element, oldAttr, attr);
} else {
exports.appendAttribute(element, attr);
}
return oldAttr;
};
exports.setAttributeValue = function (element, localName, value, prefix, namespace) {
// https://dom.spec.whatwg.org/#concept-element-attributes-set-value
if (prefix === undefined) {
prefix = null;
}
if (namespace === undefined) {
namespace = null;
}
const attribute = exports.getAttributeByNameNS(element, namespace, localName);
if (attribute === null) {
const newAttribute = attrGenerated.createImpl([], { namespace, namespacePrefix: prefix, localName, value });
exports.appendAttribute(element, newAttribute);
return;
}
exports.changeAttribute(element, attribute, value);
};
exports.removeAttributeByName = function (element, name) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-name
const attr = exports.getAttributeByName(element, name);
if (attr !== null) {
exports.removeAttribute(element, attr);
}
return attr;
};
exports.removeAttributeByNameNS = function (element, namespace, localName) {
// https://dom.spec.whatwg.org/#concept-element-attributes-remove-by-namespace
const attr = exports.getAttributeByNameNS(element, namespace, localName);
if (attr !== null) {
exports.removeAttribute(element, attr);
}
return attr;
};
exports.copyAttributeList = function (sourceElement, destElement) {
// Needed by https://dom.spec.whatwg.org/#concept-node-clone
for (const sourceAttr of sourceElement._attributes[INTERNAL].attributeList) {
const destAttr = attrGenerated.createImpl([], {
namespace: sourceAttr._namespace,
namespacePrefix: sourceAttr._namespacePrefix,
localName: sourceAttr._localName,
value: sourceAttr._value
});
exports.appendAttribute(destElement, destAttr);
}
};
exports.attributeListsEqual = function (elementA, elementB) {
// Needed by https://dom.spec.whatwg.org/#concept-node-equals
const listA = elementA._attributes[INTERNAL].attributeList;
const listB = elementB._attributes[INTERNAL].attributeList;
if (listA.length !== listB.length) {
return false;
}
for (let i = 0; i < listA.length; ++i) {
const attrA = listA[i];
if (!listB.some(attrB => equalsA(attrB))) {
return false;
}
function equalsA(attrB) {
return attrA._namespace === attrB._namespace && attrA._localName === attrB._localName &&
attrA._value === attrB._value;
}
}
return true;
};
exports.attributeNames = function (element) {
// Needed by https://dom.spec.whatwg.org/#dom-element-getattributenames
return element._attributes[INTERNAL].attributeList.map(getAttrImplQualifiedName);
};
exports.hasAttributes = function (element) {
// Needed by https://dom.spec.whatwg.org/#dom-element-hasattributes
return element._attributes[INTERNAL].attributeList.length > 0;
};
function shouldNameBeInNNMProps(element, name) {
if (element._ownerDocument._parsingMode === "html" && element._namespaceURI === "http://www.w3.org/1999/xhtml") {
return name.toLowerCase() === name;
}
return true;
}

View File

@@ -0,0 +1,87 @@
"use strict";
exports.implementation = class AttrImpl {
constructor(_, privateData) {
this._namespace = privateData.namespace !== undefined ? privateData.namespace : null;
this._namespacePrefix = privateData.namespacePrefix !== undefined ? privateData.namespacePrefix : null;
this._localName = privateData.localName;
this._value = privateData.value !== undefined ? privateData.value : "";
this._element = privateData.element !== undefined ? privateData.element : null;
this.specified = true;
}
get namespaceURI() {
return this._namespace;
}
get prefix() {
return this._namespacePrefix;
}
get localName() {
return this._localName;
}
get name() {
return exports.getAttrImplQualifiedName(this);
}
// Delegate to name
get nodeName() {
return this.name;
}
get value() {
return this._value;
}
set value(v) {
if (this._element === null) {
this._value = v;
} else {
exports.changeAttributeImpl(this._element, this, v);
}
}
// Delegate to value
get nodeValue() {
return this.value;
}
set nodeValue(v) {
this.value = v;
}
// Delegate to value
get textContent() {
return this.value;
}
set textContent(v) {
this.value = v;
}
get ownerElement() {
return this._element;
}
};
exports.changeAttributeImpl = function (element, attributeImpl, value) {
// https://dom.spec.whatwg.org/#concept-element-attributes-change
// TODO mutation observer stuff
const oldValue = attributeImpl._value;
attributeImpl._value = value;
// Run jsdom hooks; roughly correspond to spec's "An attribute is set and an attribute is changed."
element._attrModified(exports.getAttrImplQualifiedName(attributeImpl), value, oldValue);
};
exports.getAttrImplQualifiedName = function (attributeImpl) {
// https://dom.spec.whatwg.org/#concept-attribute-qualified-name
if (attributeImpl._namespacePrefix === null) {
return attributeImpl._localName;
}
return attributeImpl._namespacePrefix + ":" + attributeImpl._localName;
};

View File

@@ -0,0 +1,222 @@
"use strict";
const DOMException = require("../web-idl/DOMException");
const orderedSetParser = require("./helpers/ordered-set-parser");
// https://dom.spec.whatwg.org/#domtokenlist
const INTERNAL = Symbol("DOMTokenList internal");
class DOMTokenList {
constructor() {
throw new TypeError("Illegal constructor");
}
item(index) {
const length = this.length;
return length <= index || index < 0 ? null : this[index];
}
contains(token) {
token = String(token);
return indexOf(this, token) !== -1;
}
replace(token, newToken) {
token = String(token);
newToken = String(newToken);
validateTokens(token, newToken);
const tokenIndex = indexOf(this, token);
if (tokenIndex === -1) {
return;
}
const newTokenIndex = indexOf(this, newToken);
if (newTokenIndex !== -1) {
spliceLite(this, newTokenIndex, 1);
}
this[INTERNAL].tokens[tokenIndex] = newToken;
update(this);
}
add(/* tokens... */) {
for (let i = 0; i < arguments.length; i++) {
const token = String(arguments[i]);
validateTokens(token);
if (indexOf(this, token) === -1) {
push(this, token);
}
}
update(this);
}
remove(/* tokens... */) {
for (let i = 0; i < arguments.length; i++) {
const token = String(arguments[i]);
validateTokens(token);
const index = indexOf(this, token);
if (index !== -1) {
spliceLite(this, index, 1);
}
}
update(this);
}
// if force is true, this behaves like add
// if force is false, this behaves like remove
// if force is undefined, this behaves as one would expect toggle to
// always returns whether classList contains token after toggling
toggle(token, force) {
token = String(token);
force = force === undefined ? undefined : Boolean(force);
validateTokens(token);
const index = indexOf(this, token);
if (index !== -1) {
if (force === false || force === undefined) {
spliceLite(this, index, 1);
update(this);
return false;
}
return true;
}
if (force === false) {
return false;
}
push(this, token);
update(this);
return true;
}
get length() {
return this[INTERNAL].tokens.length;
}
get value() {
return serialize(this);
}
set value(v) {
this[INTERNAL].element.setAttribute(this[INTERNAL].attribute, v);
}
toString() {
return serialize(this);
}
}
function serialize(list) {
const value = list[INTERNAL].element.getAttribute(list[INTERNAL].attribute);
return value === null ? "" : value;
}
function validateTokens(/* tokens... */) {
for (let i = 0; i < arguments.length; i++) {
const token = String(arguments[i]);
if (token === "") {
throw new DOMException(DOMException.SYNTAX_ERR, "The token provided must not be empty.");
}
}
for (let i = 0; i < arguments.length; i++) {
const token = String(arguments[i]);
if (/\s/.test(token)) {
const whitespaceMsg = "The token provided contains HTML space characters, which are not valid in tokens.";
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, whitespaceMsg);
}
}
}
function update(list) {
const attribute = list[INTERNAL].attribute;
list[INTERNAL].element.setAttribute(attribute, list[INTERNAL].tokens.join(" "));
}
// calls indexOf on internal array
function indexOf(dtl, token) {
return dtl[INTERNAL].tokens.indexOf(token);
}
// calls push on internal array, then manually adds indexed property to dtl
function push(dtl, token) {
const len = dtl[INTERNAL].tokens.push(token);
dtl[len - 1] = token;
return len;
}
// calls splice on internal array then rewrites indexed properties of dtl
// does not allow items to be added, only removed, so splice-lite
function spliceLite(dtl, start, deleteCount) {
const tokens = dtl[INTERNAL].tokens;
const removedTokens = tokens.splice(start, deleteCount);
// remove indexed properties from list
const re = /^\d+$/;
for (const prop in dtl) {
if (re.test(prop)) {
delete dtl[prop];
}
}
// copy indexed properties from internal array
const len = tokens.length;
for (let i = 0; i < len; i++) {
dtl[i] = tokens[i];
}
return removedTokens;
}
exports.DOMTokenList = DOMTokenList;
// set dom token list without running update steps
exports.reset = function resetDOMTokenList(list, value) {
const tokens = list[INTERNAL].tokens;
spliceLite(list, 0, tokens.length);
if (value) {
for (const token of orderedSetParser(value)) {
push(list, token);
}
}
};
exports.create = function createDOMTokenList(element, attribute) {
const list = Object.create(DOMTokenList.prototype);
list[INTERNAL] = {
element,
attribute,
tokens: []
};
exports.reset(list, element.getAttribute(attribute));
return list;
};
exports.contains = function domTokenListContains(list, token, options) {
const caseInsensitive = options && options.caseInsensitive;
if (!caseInsensitive) {
return indexOf(list, token) !== -1;
}
const tokens = list[INTERNAL].tokens;
const lowerToken = token.toLowerCase();
for (let i = 0; i < tokens.length; ++i) {
if (tokens[i].toLowerCase() === lowerToken) {
return true;
}
}
return false;
};

View File

@@ -0,0 +1,61 @@
"use strict";
const Document = require("../generated/Document");
const core = require("..");
const applyDocumentFeatures = require("../../browser/documentfeatures").applyDocumentFeatures;
exports.implementation = class DOMParserImpl {
parseFromString(string, contentType) {
switch (String(contentType)) {
case "text/html": {
return createScriptingDisabledDocument("html", contentType, string);
}
case "text/xml":
case "application/xml":
case "application/xhtml+xml":
case "image/svg+xml": {
// TODO: use a strict XML parser (sax's strict mode might work?) and create parsererror elements
try {
return createScriptingDisabledDocument("xml", contentType, string);
} catch (error) {
const document = createScriptingDisabledDocument("xml", contentType);
const element = document.createElementNS(
"http://www.mozilla.org/newlayout/xml/parsererror.xml", "parsererror");
element.textContent = error.message;
document.appendChild(element);
return document;
}
}
default:
throw new TypeError("Invalid contentType");
}
}
};
function createScriptingDisabledDocument(parsingMode, contentType, string) {
const document = Document.createImpl([], {
core,
options: {
parsingMode,
encoding: "UTF-8",
contentType
// TODO: somehow set URL to active document's URL
}
});
// "scripting enabled" set to false
applyDocumentFeatures(document, {
FetchExternalResources: [],
ProcessExternalResources: false,
SkipExternalResources: false
});
if (string !== undefined) {
document._htmlToDom.appendHtmlToDocument(string, document);
}
document.close();
return document;
}

View File

@@ -0,0 +1,18 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
class CustomEventImpl extends EventImpl {
initCustomEvent(type, bubbles, cancelable, detail) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.detail = detail;
}
}
module.exports = {
implementation: CustomEventImpl
};

View File

@@ -0,0 +1,11 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
class ErrorEventImpl extends EventImpl {
}
module.exports = {
implementation: ErrorEventImpl
};

View File

@@ -0,0 +1,87 @@
"use strict";
const EventInit = require("../generated/EventInit");
class EventImpl {
constructor(args, privateData) {
const type = args[0]; // TODO: Replace with destructuring
const eventInitDict = args[1] || EventInit.convert(undefined);
this.type = type;
const wrapper = privateData.wrapper;
for (const key in eventInitDict) {
if (key in wrapper) {
this[key] = eventInitDict[key];
}
}
this.target = null;
this.currentTarget = null;
this.eventPhase = 0;
this._initializedFlag = true;
this._stopPropagationFlag = false;
this._stopImmediatePropagationFlag = false;
this._canceledFlag = false;
this._dispatchFlag = false;
this.isTrusted = privateData.isTrusted || false;
this.timeStamp = Date.now();
}
get defaultPrevented() {
return this._canceledFlag;
}
stopPropagation() {
this._stopPropagationFlag = true;
}
get cancelBubble() {
return this._stopPropagationFlag;
}
set cancelBubble(v) {
if (v) {
this._stopPropagationFlag = true;
}
}
stopImmediatePropagation() {
this._stopPropagationFlag = true;
this._stopImmediatePropagationFlag = true;
}
preventDefault() {
if (this.cancelable) {
this._canceledFlag = true;
}
}
_initialize(type, bubbles, cancelable) {
this.type = type;
this._initializedFlag = true;
this._stopPropagationFlag = false;
this._stopImmediatePropagationFlag = false;
this._canceledFlag = false;
this.isTrusted = false;
this.target = null;
this.bubbles = bubbles;
this.cancelable = cancelable;
}
initEvent(type, bubbles, cancelable) {
if (this._dispatchFlag) {
return;
}
this._initialize(type, bubbles, cancelable);
}
}
module.exports = {
implementation: EventImpl
};

View File

@@ -0,0 +1,303 @@
"use strict";
const DOMException = require("../../web-idl/DOMException");
const reportException = require("../helpers/runtime-script-errors");
const domSymbolTree = require("../helpers/internal-constants").domSymbolTree;
const idlUtils = require("../generated/utils");
const EventImpl = require("./Event-impl").implementation;
const Event = require("../generated/Event").interface;
class EventTargetImpl {
constructor() {
this._eventListeners = Object.create(null);
}
addEventListener(type, callback, options) {
// webidl2js currently can't handle neither optional arguments nor callback interfaces
if (callback === undefined || callback === null) {
callback = null;
} else if (typeof callback !== "object" && typeof callback !== "function") {
throw new TypeError("Only undefined, null, an object, or a function are allowed for the callback parameter");
}
options = normalizeEventHandlerOptions(options, ["capture", "once"]);
if (callback === null) {
return;
}
if (!this._eventListeners[type]) {
this._eventListeners[type] = [];
}
for (let i = 0; i < this._eventListeners[type].length; ++i) {
const listener = this._eventListeners[type][i];
if (listener.options.capture === options.capture && listener.callback === callback) {
return;
}
}
this._eventListeners[type].push({
callback,
options
});
}
removeEventListener(type, callback, options) {
if (callback === undefined || callback === null) {
callback = null;
} else if (typeof callback !== "object" && typeof callback !== "function") {
throw new TypeError("Only undefined, null, an object, or a function are allowed for the callback parameter");
}
options = normalizeEventHandlerOptions(options, ["capture"]);
if (callback === null) {
// Optimization, not in the spec.
return;
}
if (!this._eventListeners[type]) {
return;
}
for (let i = 0; i < this._eventListeners[type].length; ++i) {
const listener = this._eventListeners[type][i];
if (listener.callback === callback && listener.options.capture === options.capture) {
this._eventListeners[type].splice(i, 1);
break;
}
}
}
dispatchEvent(eventImpl) {
if (!(eventImpl instanceof EventImpl)) {
throw new TypeError("Argument to dispatchEvent must be an Event");
}
if (eventImpl._dispatchFlag || !eventImpl._initializedFlag) {
throw new DOMException(DOMException.INVALID_STATE_ERR, "Tried to dispatch an uninitialized event");
}
if (eventImpl.eventPhase !== Event.NONE) {
throw new DOMException(DOMException.INVALID_STATE_ERR, "Tried to dispatch a dispatching event");
}
eventImpl.isTrusted = false;
return this._dispatch(eventImpl);
}
_dispatch(eventImpl, targetOverride) {
eventImpl._dispatchFlag = true;
eventImpl.target = targetOverride || this;
const eventPath = [];
let targetParent = domSymbolTree.parent(eventImpl.target);
let target = eventImpl.target;
while (targetParent) {
eventPath.push(targetParent);
target = targetParent;
targetParent = domSymbolTree.parent(targetParent);
}
if (eventImpl.type !== "load" && target._defaultView) {
// https://html.spec.whatwg.org/#events-and-the-window-object
eventPath.push(idlUtils.implForWrapper(target._defaultView));
}
eventImpl.eventPhase = Event.CAPTURING_PHASE;
for (let i = eventPath.length - 1; i >= 0; --i) {
if (eventImpl._stopPropagationFlag) {
break;
}
const object = eventPath[i];
const objectImpl = idlUtils.implForWrapper(object) || object; // window :(
const eventListeners = objectImpl._eventListeners[eventImpl.type];
invokeEventListeners(eventListeners, object, eventImpl);
}
eventImpl.eventPhase = Event.AT_TARGET;
if (!eventImpl._stopPropagationFlag) {
invokeInlineListeners(eventImpl.target, eventImpl);
if (this._eventListeners[eventImpl.type]) {
const eventListeners = this._eventListeners[eventImpl.type];
invokeEventListeners(eventListeners, eventImpl.target, eventImpl);
}
}
if (eventImpl.bubbles) {
eventImpl.eventPhase = Event.BUBBLING_PHASE;
for (let i = 0; i < eventPath.length; ++i) {
if (eventImpl._stopPropagationFlag) {
break;
}
const object = eventPath[i];
const objectImpl = idlUtils.implForWrapper(object) || object; // window :(
const eventListeners = objectImpl._eventListeners[eventImpl.type];
invokeInlineListeners(object, eventImpl);
invokeEventListeners(eventListeners, object, eventImpl);
}
}
eventImpl._dispatchFlag = false;
eventImpl._stopPropagationFlag = false;
eventImpl._stopImmediatePropagationFlag = false;
eventImpl.eventPhase = Event.NONE;
eventImpl.currentTarget = null;
return !eventImpl._canceledFlag;
}
}
module.exports = {
implementation: EventTargetImpl
};
function invokeInlineListeners(object, event) {
const wrapper = idlUtils.wrapperForImpl(object);
const inlineListener = getListenerForInlineEventHandler(wrapper, event.type);
if (inlineListener) {
const document = object._ownerDocument || (wrapper && (wrapper._document || wrapper._ownerDocument));
// Will be falsy for windows that have closed
if (document && (!object.nodeName || document.implementation._hasFeature("ProcessExternalResources", "script"))) {
invokeEventListeners([{
callback: inlineListener,
options: normalizeEventHandlerOptions(false, ["capture", "once"])
}], object, event);
}
}
}
function invokeEventListeners(listeners, target, eventImpl) {
const wrapper = idlUtils.wrapperForImpl(target);
const document = target._ownerDocument || (wrapper && (wrapper._document || wrapper._ownerDocument));
// Will be falsy for windows that have closed
if (!document) {
return;
}
// workaround for events emitted on window (window-proxy)
// the wrapper is the root window instance, but we only want to expose the vm proxy at all times
if (wrapper._document) {
target = idlUtils.implForWrapper(wrapper._document)._defaultView;
}
eventImpl.currentTarget = target;
if (!listeners) {
return;
}
const handlers = listeners.slice();
for (let i = 0; i < handlers.length; ++i) {
if (eventImpl._stopImmediatePropagationFlag) {
return;
}
const listener = handlers[i];
const capture = listener.options.capture;
const once = listener.options.once;
// const passive = listener.options.passive;
if (listeners.indexOf(listener) === -1 ||
(eventImpl.eventPhase === Event.CAPTURING_PHASE && !capture) ||
(eventImpl.eventPhase === Event.BUBBLING_PHASE && capture)) {
continue;
}
if (once) {
listeners.splice(listeners.indexOf(listener), 1);
}
try {
if (typeof listener.callback === "object") {
if (typeof listener.callback.handleEvent === "function") {
listener.callback.handleEvent(idlUtils.wrapperForImpl(eventImpl));
}
} else {
listener.callback.call(idlUtils.wrapperForImpl(eventImpl.currentTarget), idlUtils.wrapperForImpl(eventImpl));
}
} catch (e) {
let window = null;
if (wrapper && wrapper._document) {
// Triggered by Window
window = wrapper;
} else if (target._ownerDocument) {
// Triggered by most webidl2js'ed instances
window = target._ownerDocument._defaultView;
} else if (wrapper._ownerDocument) {
// Currently triggered by XHR and some other non-webidl2js things
window = wrapper._ownerDocument._defaultView;
}
if (window) {
reportException(window, e);
}
// Errors in window-less documents just get swallowed... can you think of anything better?
}
}
}
const wrappedListener = Symbol("inline event listener wrapper");
/**
* Normalize the event listeners options argument in order to get always a valid options object
* @param {Object} options - user defined options
* @param {Array} defaultBoolKeys - boolean properties that should belong to the options object
* @returns {Object} object containing at least the "defaultBoolKeys"
*/
function normalizeEventHandlerOptions(options, defaultBoolKeys) {
const returnValue = {};
// no need to go further here
if (typeof options === "boolean" || options === null || typeof options === "undefined") {
returnValue.capture = Boolean(options);
return returnValue;
}
// non objects options so we typecast its value as "capture" value
if (typeof options !== "object") {
returnValue.capture = Boolean(options);
// at this point we don't need to loop the "capture" key anymore
defaultBoolKeys = defaultBoolKeys.filter(k => k !== "capture");
}
for (const key of defaultBoolKeys) {
returnValue[key] = Boolean(options[key]);
}
return returnValue;
}
function getListenerForInlineEventHandler(target, type) {
const callback = target["on" + type];
if (!callback) { // TODO event handlers: only check null
return null;
}
if (!callback[wrappedListener]) {
// https://html.spec.whatwg.org/multipage/webappapis.html#the-event-handler-processing-algorithm
callback[wrappedListener] = function (E) {
const isWindowError = E.constructor.name === "ErrorEvent" && type === "error"; // TODO branding
let returnValue;
if (isWindowError) {
returnValue = callback.call(E.currentTarget, E.message, E.filename, E.lineno, E.colno, E.error);
} else {
returnValue = callback.call(E.currentTarget, E);
}
if (type === "mouseover" || isWindowError) {
if (returnValue === true) {
E.preventDefault();
}
} else if (returnValue === false) {
E.preventDefault();
}
};
}
return callback[wrappedListener];
}

View File

@@ -0,0 +1,4 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
exports.implementation = class FocusEventImpl extends EventImpl { };

View File

@@ -0,0 +1,11 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
class HashChangeEventImpl extends EventImpl {
}
module.exports = {
implementation: HashChangeEventImpl
};

View File

@@ -0,0 +1,21 @@
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
class KeyboardEventImpl extends UIEventImpl {
initKeyboardEvent(type, bubbles, cancelable, view, key, location, modifiersList, repeat, locale) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable, view, key);
this.location = location;
this.modifiersList = modifiersList;
this.repeat = repeat;
this.locale = locale;
}
}
module.exports = {
implementation: KeyboardEventImpl
};

View File

@@ -0,0 +1,22 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
class MessageEventImpl extends EventImpl {
initMessageEvent(type, bubbles, cancelable, data, origin, lastEventId, source, ports) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.data = data;
this.origin = origin;
this.lastEventId = lastEventId;
this.source = source;
this.ports = ports;
}
}
module.exports = {
implementation: MessageEventImpl
};

View File

@@ -0,0 +1,28 @@
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
class MouseEventImpl extends UIEventImpl {
initMouseEvent(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY,
ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget) {
if (this._dispatchFlag) {
return;
}
this.initUIEvent(type, bubbles, cancelable, view, detail);
this.screenX = screenX;
this.screenY = screenY;
this.clientX = clientX;
this.clientY = clientY;
this.ctrlKey = ctrlKey;
this.altKey = altKey;
this.shiftKey = shiftKey;
this.metaKey = metaKey;
this.button = button;
this.relatedTarget = relatedTarget;
}
}
module.exports = {
implementation: MouseEventImpl
};

View File

@@ -0,0 +1,4 @@
"use strict";
const EventImpl = require("./Event-impl.js").implementation;
exports.implementation = class PopStateEventImpl extends EventImpl {};

View File

@@ -0,0 +1,11 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
class ProgressEventImpl extends EventImpl {
}
module.exports = {
implementation: ProgressEventImpl
};

View File

@@ -0,0 +1,11 @@
"use strict";
const UIEventImpl = require("./UIEvent-impl").implementation;
class TouchEventImpl extends UIEventImpl {
}
module.exports = {
implementation: TouchEventImpl
};

View File

@@ -0,0 +1,19 @@
"use strict";
const EventImpl = require("./Event-impl").implementation;
class UIEventImpl extends EventImpl {
initUIEvent(type, bubbles, cancelable, view, detail) {
if (this._dispatchFlag) {
return;
}
this.initEvent(type, bubbles, cancelable);
this.view = view;
this.detail = detail;
}
}
module.exports = {
implementation: UIEventImpl
};

View File

@@ -0,0 +1,105 @@
"use strict";
const idlUtils = require("../generated/utils");
const conversions = require("webidl-conversions");
const Blob = require("../generated/Blob");
exports.implementation = class BlobImpl {
constructor(args) {
const parts = args[0];
const properties = args[1];
const buffers = [];
if (parts !== undefined) {
if (parts === null || typeof parts !== "object" || typeof parts[Symbol.iterator] !== "function") {
throw new TypeError("parts must be an iterable object");
}
const arr = [];
for (const part of parts) {
if (part instanceof ArrayBuffer || ArrayBuffer.isView(part) || Blob.is(part)) {
arr.push(idlUtils.tryImplForWrapper(part));
} else {
arr.push(conversions.USVString(part));
}
}
for (const part of arr) {
let buffer;
if (part instanceof ArrayBuffer) {
buffer = new Buffer(new Uint8Array(part));
} else if (ArrayBuffer.isView(part)) {
buffer = new Buffer(new Uint8Array(part.buffer, part.byteOffset, part.byteLength));
} else if (Blob.isImpl(part)) {
buffer = part._buffer;
} else {
buffer = new Buffer(part);
}
buffers.push(buffer);
}
}
this._buffer = Buffer.concat(buffers);
this.type = properties.type;
if (/[^\u0020-\u007E]/.test(this.type)) {
this.type = "";
} else {
this.type = this.type.toLowerCase();
}
this.isClosed = false;
}
get size() {
return this.isClosed ? 0 : this._buffer.length;
}
slice(start, end, contentType) {
const size = this.size;
let relativeStart;
let relativeEnd;
let relativeContentType;
if (start === undefined) {
relativeStart = 0;
} else if (start < 0) {
relativeStart = Math.max(size + start, 0);
} else {
relativeStart = Math.min(start, size);
}
if (end === undefined) {
relativeEnd = size;
} else if (end < 0) {
relativeEnd = Math.max(size + end, 0);
} else {
relativeEnd = Math.min(end, size);
}
if (contentType === undefined) {
relativeContentType = "";
} else {
// sanitization (lower case and invalid char check) is done in the
// constructor
relativeContentType = contentType;
}
const span = Math.max(relativeEnd - relativeStart, 0);
const buffer = this._buffer;
const slicedBuffer = buffer.slice(
relativeStart,
relativeStart + span
);
const blob = Blob.createImpl([[], { type: relativeContentType }], {});
blob.isClosed = this.isClosed;
blob._buffer = slicedBuffer;
return blob;
}
close() {
this.isClosed = true;
}
};

View File

@@ -0,0 +1,15 @@
"use strict";
const BlobImpl = require("./Blob-impl").implementation;
exports.implementation = class FileImpl extends BlobImpl {
constructor(args, privateData) {
const fileBits = args[0];
const fileName = args[1];
const options = args[2];
super([fileBits, options], privateData);
this.name = fileName.replace(/\//g, ":");
this.lastModified = "lastModified" in options ? options.lastModified : Date.now();
}
};

View File

@@ -0,0 +1,10 @@
"use strict";
exports.implementation = class FileListImpl extends Array {
constructor() {
super(0);
}
item(index) {
return this[index] || null;
}
};

View File

@@ -0,0 +1,131 @@
"use strict";
const whatwgEncoding = require("whatwg-encoding");
const parseContentType = require("content-type-parser");
const querystring = require("querystring");
const DOMException = require("../../web-idl/DOMException");
const EventTargetImpl = require("../events/EventTarget-impl").implementation;
const Blob = require("../generated/Blob");
const ProgressEvent = require("../generated/ProgressEvent");
const READY_STATES = Object.freeze({
EMPTY: 0,
LOADING: 1,
DONE: 2
});
exports.implementation = class FileReaderImpl extends EventTargetImpl {
constructor(args, privateData) {
super([], privateData);
this.error = null;
this.readyState = READY_STATES.EMPTY;
this.result = null;
this.onloadstart = null;
this.onprogress = null;
this.onload = null;
this.onabort = null;
this.onerror = null;
this.onloadend = null;
this._ownerDocument = privateData.window.document;
}
readAsArrayBuffer(file) {
this._readFile(file, "buffer");
}
readAsDataURL(file) {
this._readFile(file, "dataURL");
}
readAsText(file, encoding) {
this._readFile(file, "text", whatwgEncoding.labelToName(encoding) || "UTF-8");
}
abort() {
if (this.readyState === READY_STATES.DONE || this.readyState === READY_STATES.EMPTY) {
this.result = null;
return;
}
if (this.readyState === READY_STATES.LOADING) {
this.readyState = READY_STATES.DONE;
}
this._fireProgressEvent("abort");
this._fireProgressEvent("loadend");
}
_fireProgressEvent(name, props) {
const event = ProgressEvent.createImpl([name, Object.assign({ bubbles: false, cancelable: false }, props)], {});
this.dispatchEvent(event);
}
_readFile(file, format, encoding) {
if (!Blob.isImpl(file)) {
throw new TypeError("file argument must be a Blob");
}
if (this.readyState === READY_STATES.LOADING) {
throw new DOMException(DOMException.INVALID_STATE_ERR);
}
if (file.isClosed) {
this.error = new DOMException(DOMException.INVALID_STATE_ERR);
this._fireProgressEvent("error");
}
this.readyState = READY_STATES.LOADING;
this._fireProgressEvent("loadstart");
process.nextTick(() => {
let data = file._buffer;
if (!data) {
data = new Buffer("");
}
this._fireProgressEvent("progress", {
lengthComputable: !isNaN(file.size),
total: file.size,
loaded: data.length
});
process.nextTick(() => {
switch (format) {
default:
case "buffer": {
this.result = (new Uint8Array(data)).buffer;
break;
}
case "dataURL": {
let dataUrl = "data:";
const contentType = parseContentType(file.type);
if (contentType && contentType.isText()) {
const fallbackEncoding = whatwgEncoding.getBOMEncoding(data) ||
whatwgEncoding.labelToName(contentType.get("charset")) || "UTF-8";
const decoded = whatwgEncoding.decode(data, fallbackEncoding);
contentType.set("charset", encoding);
dataUrl += contentType.toString();
dataUrl += ",";
dataUrl += querystring.escape(decoded);
} else {
if (contentType) {
dataUrl += contentType.toString();
}
dataUrl += ";base64,";
dataUrl += data.toString("base64");
}
this.result = dataUrl;
break;
}
case "text": {
this.result = whatwgEncoding.decode(data, encoding);
break;
}
}
this.readyState = READY_STATES.DONE;
this._fireProgressEvent("load");
this._fireProgressEvent("loadend");
});
});
}
};

View File

@@ -0,0 +1,3 @@
"use strict";
exports.formData = Symbol("entries");

View File

@@ -0,0 +1,34 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventListenerOptions = require("./EventListenerOptions");
module.exports = {
convertInherit(obj, ret) {
EventListenerOptions.convertInherit(obj, ret);
let key, value;
key = "once";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};

View File

@@ -0,0 +1,169 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function Attr() {
throw new TypeError("Illegal constructor");
}
Attr.prototype.toString = function () {
if (this === Attr.prototype) {
return "[object AttrPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(Attr.prototype, "namespaceURI", {
get() {
return this[impl].namespaceURI;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "prefix", {
get() {
return this[impl].prefix;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "localName", {
get() {
return this[impl].localName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "name", {
get() {
return this[impl].name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "nodeName", {
get() {
return this[impl].nodeName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "value", {
get() {
return this[impl].value;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].value = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "nodeValue", {
get() {
return this[impl].nodeValue;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].nodeValue = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "textContent", {
get() {
return this[impl].textContent;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].textContent = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "ownerElement", {
get() {
return utils.tryWrapperForImpl(this[impl].ownerElement);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Attr.prototype, "specified", {
get() {
return this[impl].specified;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Attr.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Attr.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Attr,
expose: {
Window: { Attr: Attr }
}
};
module.exports = iface;
const Impl = require("../attributes/Attr-impl.js");

View File

@@ -0,0 +1,140 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
const convertBlobPropertyBag = require("./BlobPropertyBag").convert;
function Blob() {
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[1] = convertBlobPropertyBag(args[1]);
iface.setup(this, args);
}
Blob.prototype.slice = function slice() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["long long"](args[0], { clamp: true });
}
if (args[1] !== undefined) {
args[1] = conversions["long long"](args[1], { clamp: true });
}
if (args[2] !== undefined) {
args[2] = conversions["DOMString"](args[2]);
}
return utils.tryWrapperForImpl(this[impl].slice.apply(this[impl], args));
};
Blob.prototype.close = function close() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].close.apply(this[impl], args);
};
Blob.prototype.toString = function () {
if (this === Blob.prototype) {
return "[object BlobPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(Blob.prototype, "size", {
get() {
return this[impl].size;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Blob.prototype, "type", {
get() {
return this[impl].type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Blob.prototype, "isClosed", {
get() {
return this[impl].isClosed;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Blob.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Blob.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Blob,
expose: {
Window: { Blob: Blob },
Worker: { Blob: Blob }
}
};
module.exports = iface;
const Impl = require("../file-api/Blob-impl.js");

View File

@@ -0,0 +1,32 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
module.exports = {
convertInherit(obj, ret) {
let key, value;
key = "type";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
} else {
ret[key] = "";
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};

View File

@@ -0,0 +1,82 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Text = require("./Text.js");
const impl = utils.implSymbol;
function CDATASection() {
throw new TypeError("Illegal constructor");
}
CDATASection.prototype = Object.create(Text.interface.prototype);
CDATASection.prototype.constructor = CDATASection;
CDATASection.prototype.toString = function () {
if (this === CDATASection.prototype) {
return "[object CDATASectionPrototype]";
}
return Text.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(CDATASection.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(CDATASection.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Text._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: CDATASection,
expose: {
Window: { CDATASection: CDATASection }
}
};
module.exports = iface;
const Impl = require("../nodes/CDATASection-impl.js");

View File

@@ -0,0 +1,189 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const ChildNode = require("./ChildNode.js");
const NonDocumentTypeChildNode = require("./NonDocumentTypeChildNode.js");
function CharacterData() {
throw new TypeError("Illegal constructor");
}
CharacterData.prototype = Object.create(Node.interface.prototype);
CharacterData.prototype.constructor = CharacterData;
mixin(CharacterData.prototype, ChildNode.interface.prototype);
ChildNode.mixedInto.push(CharacterData);
mixin(CharacterData.prototype, NonDocumentTypeChildNode.interface.prototype);
NonDocumentTypeChildNode.mixedInto.push(CharacterData);
CharacterData.prototype.substringData = function substringData(offset, count) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'substringData' on 'CharacterData': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["unsigned long"](args[1]);
return this[impl].substringData.apply(this[impl], args);
};
CharacterData.prototype.appendData = function appendData(data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'appendData' on 'CharacterData': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].appendData.apply(this[impl], args);
};
CharacterData.prototype.insertData = function insertData(offset, data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'insertData' on 'CharacterData': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["DOMString"](args[1]);
return this[impl].insertData.apply(this[impl], args);
};
CharacterData.prototype.deleteData = function deleteData(offset, count) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'deleteData' on 'CharacterData': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["unsigned long"](args[1]);
return this[impl].deleteData.apply(this[impl], args);
};
CharacterData.prototype.replaceData = function replaceData(offset, count, data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 3) {
throw new TypeError("Failed to execute 'replaceData' on 'CharacterData': 3 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["unsigned long"](args[1]);
args[2] = conversions["DOMString"](args[2]);
return this[impl].replaceData.apply(this[impl], args);
};
CharacterData.prototype.toString = function () {
if (this === CharacterData.prototype) {
return "[object CharacterDataPrototype]";
}
return Node.interface.prototype.toString.call(this);
};
Object.defineProperty(CharacterData.prototype, "data", {
get() {
return this[impl].data;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].data = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(CharacterData.prototype, "length", {
get() {
return this[impl].length;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(CharacterData.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(CharacterData.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Node._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: CharacterData,
expose: {
Window: { CharacterData: CharacterData }
}
};
module.exports = iface;
const Impl = require("../nodes/CharacterData-impl.js");

View File

@@ -0,0 +1,92 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function ChildNode() {
throw new TypeError("Illegal constructor");
}
ChildNode.prototype.remove = function remove() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].remove.apply(this[impl], args);
};
ChildNode.prototype.toString = function () {
if (this === ChildNode.prototype) {
return "[object ChildNodePrototype]";
}
return this[impl].toString();
};
ChildNode.prototype[Symbol.unscopables] = {
"remove": true
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ChildNode.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ChildNode.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ChildNode,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/ChildNode-impl.js");

View File

@@ -0,0 +1,92 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const CharacterData = require("./CharacterData.js");
const impl = utils.implSymbol;
function Comment() {
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
} else {
args[0] = "";
}
iface.setup(this, args);
}
Comment.prototype = Object.create(CharacterData.interface.prototype);
Comment.prototype.constructor = Comment;
Comment.prototype.toString = function () {
if (this === Comment.prototype) {
return "[object CommentPrototype]";
}
return CharacterData.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Comment.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Comment.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
CharacterData._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Comment,
expose: {
Window: { Comment: Comment }
}
};
module.exports = iface;
const Impl = require("../nodes/Comment-impl.js");

View File

@@ -0,0 +1,123 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Event = require("./Event.js");
const impl = utils.implSymbol;
const convertCustomEventInit = require("./CustomEventInit").convert;
function CustomEvent(type) {
if (!this || this[impl] || !(this instanceof CustomEvent)) {
throw new TypeError("Failed to construct 'CustomEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'CustomEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertCustomEventInit(args[1]);
iface.setup(this, args);
}
CustomEvent.prototype = Object.create(Event.interface.prototype);
CustomEvent.prototype.constructor = CustomEvent;
CustomEvent.prototype.initCustomEvent = function initCustomEvent(type, bubbles, cancelable, detail) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 4) {
throw new TypeError("Failed to execute 'initCustomEvent' on 'CustomEvent': 4 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 4; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["boolean"](args[1]);
args[2] = conversions["boolean"](args[2]);
args[3] = conversions["any"](args[3]);
return this[impl].initCustomEvent.apply(this[impl], args);
};
CustomEvent.prototype.toString = function () {
if (this === CustomEvent.prototype) {
return "[object CustomEventPrototype]";
}
return Event.interface.prototype.toString.call(this);
};
Object.defineProperty(CustomEvent.prototype, "detail", {
get() {
return this[impl].detail;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(CustomEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(CustomEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Event._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: CustomEvent,
expose: {
Window: { CustomEvent: CustomEvent },
Worker: { CustomEvent: CustomEvent }
}
};
module.exports = iface;
const Impl = require("../events/CustomEvent-impl.js");

View File

@@ -0,0 +1,34 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit");
module.exports = {
convertInherit(obj, ret) {
EventInit.convertInherit(obj, ret);
let key, value;
key = "detail";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["any"](value);
} else {
ret[key] = null;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};

View File

@@ -0,0 +1,143 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function DOMImplementation() {
throw new TypeError("Illegal constructor");
}
DOMImplementation.prototype.createDocumentType = function createDocumentType(qualifiedName, publicId, systemId) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 3) {
throw new TypeError("Failed to execute 'createDocumentType' on 'DOMImplementation': 3 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["DOMString"](args[1]);
args[2] = conversions["DOMString"](args[2]);
return utils.tryWrapperForImpl(this[impl].createDocumentType.apply(this[impl], args));
};
DOMImplementation.prototype.createDocument = function createDocument(namespace, qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'createDocument' on 'DOMImplementation': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1], { treatNullAsEmptyString: true });
if (args[2] === null || args[2] === undefined) {
args[2] = null;
} else {
}
return utils.tryWrapperForImpl(this[impl].createDocument.apply(this[impl], args));
};
DOMImplementation.prototype.createHTMLDocument = function createHTMLDocument() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
}
return utils.tryWrapperForImpl(this[impl].createHTMLDocument.apply(this[impl], args));
};
DOMImplementation.prototype.hasFeature = function hasFeature() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].hasFeature.apply(this[impl], args);
};
DOMImplementation.prototype.toString = function () {
if (this === DOMImplementation.prototype) {
return "[object DOMImplementationPrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(DOMImplementation.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(DOMImplementation.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: DOMImplementation,
expose: {
Window: { DOMImplementation: DOMImplementation }
}
};
module.exports = iface;
const Impl = require("../nodes/DOMImplementation-impl.js");

View File

@@ -0,0 +1,97 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function DOMParser() {
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
iface.setup(this, args);
}
DOMParser.prototype.parseFromString = function parseFromString(str, type) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'parseFromString' on 'DOMParser': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].parseFromString.apply(this[impl], args));
};
DOMParser.prototype.toString = function () {
if (this === DOMParser.prototype) {
return "[object DOMParserPrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(DOMParser.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(DOMParser.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: DOMParser,
expose: {
Window: { DOMParser: DOMParser }
}
};
module.exports = iface;
const Impl = require("../domparsing/DOMParser-impl.js");

View File

@@ -0,0 +1,751 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const GlobalEventHandlers = require("./GlobalEventHandlers.js");
const NonElementParentNode = require("./NonElementParentNode.js");
const ParentNode = require("./ParentNode.js");
function Document() {
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
iface.setup(this, args);
}
Document.prototype = Object.create(Node.interface.prototype);
Document.prototype.constructor = Document;
mixin(Document.prototype, GlobalEventHandlers.interface.prototype);
GlobalEventHandlers.mixedInto.push(Document);
mixin(Document.prototype, NonElementParentNode.interface.prototype);
NonElementParentNode.mixedInto.push(Document);
mixin(Document.prototype, ParentNode.interface.prototype);
ParentNode.mixedInto.push(Document);
Document.prototype.getElementsByTagName = function getElementsByTagName(localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementsByTagName' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementsByTagName.apply(this[impl], args));
};
Document.prototype.getElementsByTagNameNS = function getElementsByTagNameNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'getElementsByTagNameNS' on 'Document': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].getElementsByTagNameNS.apply(this[impl], args));
};
Document.prototype.getElementsByClassName = function getElementsByClassName(classNames) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementsByClassName' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementsByClassName.apply(this[impl], args));
};
Document.prototype.createElement = function createElement(localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createElement' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createElement.apply(this[impl], args));
};
Document.prototype.createElementNS = function createElementNS(namespace, qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'createElementNS' on 'Document': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].createElementNS.apply(this[impl], args));
};
Document.prototype.createDocumentFragment = function createDocumentFragment() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].createDocumentFragment.apply(this[impl], args));
};
Document.prototype.createTextNode = function createTextNode(data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createTextNode' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createTextNode.apply(this[impl], args));
};
Document.prototype.createCDATASection = function createCDATASection(data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createCDATASection' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createCDATASection.apply(this[impl], args));
};
Document.prototype.createComment = function createComment(data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createComment' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createComment.apply(this[impl], args));
};
Document.prototype.createProcessingInstruction = function createProcessingInstruction(target, data) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'createProcessingInstruction' on 'Document': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].createProcessingInstruction.apply(this[impl], args));
};
Document.prototype.importNode = function importNode(node) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'importNode' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] !== undefined) {
args[1] = conversions["boolean"](args[1]);
} else {
args[1] = false;
}
return utils.tryWrapperForImpl(this[impl].importNode.apply(this[impl], args));
};
Document.prototype.adoptNode = function adoptNode(node) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'adoptNode' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].adoptNode.apply(this[impl], args));
};
Document.prototype.createAttribute = function createAttribute(localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createAttribute' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createAttribute.apply(this[impl], args));
};
Document.prototype.createAttributeNS = function createAttributeNS(namespace, qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'createAttributeNS' on 'Document': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].createAttributeNS.apply(this[impl], args));
};
Document.prototype.createEvent = function createEvent(_interface) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createEvent' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].createEvent.apply(this[impl], args));
};
Document.prototype.createTreeWalker = function createTreeWalker(root) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'createTreeWalker' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] !== undefined) {
args[1] = conversions["unsigned long"](args[1]);
} else {
args[1] = 4294967295;
}
if (args[2] === null || args[2] === undefined) {
args[2] = null;
} else {
}
return utils.tryWrapperForImpl(this[impl].createTreeWalker.apply(this[impl], args));
};
Document.prototype.getElementsByName = function getElementsByName(elementName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementsByName' on 'Document': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementsByName.apply(this[impl], args));
};
Document.prototype.open = function open() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
} else {
args[0] = "text/html";
}
if (args[1] !== undefined) {
args[1] = conversions["DOMString"](args[1]);
} else {
args[1] = "";
}
return utils.tryWrapperForImpl(this[impl].open.apply(this[impl], args));
};
Document.prototype.close = function close() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].close.apply(this[impl], args);
};
Document.prototype.write = function write() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
}
return this[impl].write.apply(this[impl], args);
};
Document.prototype.writeln = function writeln() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
}
return this[impl].writeln.apply(this[impl], args);
};
Document.prototype.hasFocus = function hasFocus() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].hasFocus.apply(this[impl], args);
};
Document.prototype.toString = function () {
if (this === Document.prototype) {
return "[object DocumentPrototype]";
}
return Node.interface.prototype.toString.call(this);
};
Object.defineProperty(Document.prototype, "implementation", {
get() {
return utils.tryWrapperForImpl(this[impl].implementation);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "URL", {
get() {
return this[impl].URL;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "documentURI", {
get() {
return this[impl].documentURI;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "origin", {
get() {
return this[impl].origin;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "compatMode", {
get() {
return this[impl].compatMode;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "characterSet", {
get() {
return this[impl].characterSet;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "charset", {
get() {
return this[impl].charset;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "inputEncoding", {
get() {
return this[impl].inputEncoding;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "contentType", {
get() {
return this[impl].contentType;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "doctype", {
get() {
return utils.tryWrapperForImpl(this[impl].doctype);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "documentElement", {
get() {
return utils.tryWrapperForImpl(this[impl].documentElement);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "referrer", {
get() {
return this[impl].referrer;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "cookie", {
get() {
return this[impl].cookie;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].cookie = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "lastModified", {
get() {
return this[impl].lastModified;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "readyState", {
get() {
return utils.tryWrapperForImpl(this[impl].readyState);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "title", {
get() {
return this[impl].title;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].title = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "body", {
get() {
return utils.tryWrapperForImpl(this[impl].body);
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
}
this[impl].body = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "head", {
get() {
return utils.tryWrapperForImpl(this[impl].head);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "images", {
get() {
return utils.tryWrapperForImpl(this[impl].images);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "embeds", {
get() {
return utils.tryWrapperForImpl(this[impl].embeds);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "plugins", {
get() {
return utils.tryWrapperForImpl(this[impl].plugins);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "links", {
get() {
return utils.tryWrapperForImpl(this[impl].links);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "forms", {
get() {
return utils.tryWrapperForImpl(this[impl].forms);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "scripts", {
get() {
return utils.tryWrapperForImpl(this[impl].scripts);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "currentScript", {
get() {
return utils.tryWrapperForImpl(this[impl].currentScript);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "defaultView", {
get() {
return utils.tryWrapperForImpl(this[impl].defaultView);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "activeElement", {
get() {
return utils.tryWrapperForImpl(this[impl].activeElement);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "onreadystatechange", {
get() {
return utils.tryWrapperForImpl(this[impl].onreadystatechange);
},
set(V) {
this[impl].onreadystatechange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "anchors", {
get() {
return utils.tryWrapperForImpl(this[impl].anchors);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "applets", {
get() {
return utils.tryWrapperForImpl(this[impl].applets);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "styleSheets", {
get() {
return utils.tryWrapperForImpl(this[impl].styleSheets);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "hidden", {
get() {
return this[impl].hidden;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "visibilityState", {
get() {
return utils.tryWrapperForImpl(this[impl].visibilityState);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Document.prototype, "onvisibilitychange", {
get() {
return utils.tryWrapperForImpl(this[impl].onvisibilitychange);
},
set(V) {
this[impl].onvisibilitychange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Document.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Document.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Node._internalSetup(obj);
Object.defineProperty(obj, "location", {
get() {
return utils.tryWrapperForImpl(obj[impl].location);
},
set(V) {
this.location.href = V;
},
enumerable: true,
configurable: false
});
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Document,
expose: {
Window: { Document: Document }
}
};
module.exports = iface;
const Impl = require("../nodes/Document-impl.js");

View File

@@ -0,0 +1,91 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const ParentNode = require("./ParentNode.js");
function DocumentFragment() {
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
iface.setup(this, args);
}
DocumentFragment.prototype = Object.create(Node.interface.prototype);
DocumentFragment.prototype.constructor = DocumentFragment;
mixin(DocumentFragment.prototype, ParentNode.interface.prototype);
ParentNode.mixedInto.push(DocumentFragment);
DocumentFragment.prototype.toString = function () {
if (this === DocumentFragment.prototype) {
return "[object DocumentFragmentPrototype]";
}
return Node.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(DocumentFragment.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(DocumentFragment.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Node._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: DocumentFragment,
expose: {
Window: { DocumentFragment: DocumentFragment }
}
};
module.exports = iface;
const Impl = require("../nodes/DocumentFragment-impl.js");

View File

@@ -0,0 +1,110 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const ChildNode = require("./ChildNode.js");
function DocumentType() {
throw new TypeError("Illegal constructor");
}
DocumentType.prototype = Object.create(Node.interface.prototype);
DocumentType.prototype.constructor = DocumentType;
mixin(DocumentType.prototype, ChildNode.interface.prototype);
ChildNode.mixedInto.push(DocumentType);
DocumentType.prototype.toString = function () {
if (this === DocumentType.prototype) {
return "[object DocumentTypePrototype]";
}
return Node.interface.prototype.toString.call(this);
};
Object.defineProperty(DocumentType.prototype, "name", {
get() {
return this[impl].name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DocumentType.prototype, "publicId", {
get() {
return this[impl].publicId;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DocumentType.prototype, "systemId", {
get() {
return this[impl].systemId;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(DocumentType.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(DocumentType.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Node._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: DocumentType,
expose: {
Window: { DocumentType: DocumentType }
}
};
module.exports = iface;
const Impl = require("../nodes/DocumentType-impl.js");

View File

@@ -0,0 +1,624 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Node = require("./Node.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const ChildNode = require("./ChildNode.js");
const NonDocumentTypeChildNode = require("./NonDocumentTypeChildNode.js");
const ParentNode = require("./ParentNode.js");
function Element() {
throw new TypeError("Illegal constructor");
}
Element.prototype = Object.create(Node.interface.prototype);
Element.prototype.constructor = Element;
mixin(Element.prototype, ChildNode.interface.prototype);
ChildNode.mixedInto.push(Element);
mixin(Element.prototype, NonDocumentTypeChildNode.interface.prototype);
NonDocumentTypeChildNode.mixedInto.push(Element);
mixin(Element.prototype, ParentNode.interface.prototype);
ParentNode.mixedInto.push(Element);
Element.prototype.hasAttributes = function hasAttributes() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].hasAttributes.apply(this[impl], args);
};
Element.prototype.getAttributeNames = function getAttributeNames() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].getAttributeNames.apply(this[impl], args));
};
Element.prototype.getAttribute = function getAttribute(qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getAttribute' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].getAttribute.apply(this[impl], args);
};
Element.prototype.getAttributeNS = function getAttributeNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'getAttributeNS' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return this[impl].getAttributeNS.apply(this[impl], args);
};
Element.prototype.setAttribute = function setAttribute(qualifiedName, value) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'setAttribute' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["DOMString"](args[1]);
return this[impl].setAttribute.apply(this[impl], args);
};
Element.prototype.setAttributeNS = function setAttributeNS(namespace, qualifiedName, value) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 3) {
throw new TypeError("Failed to execute 'setAttributeNS' on 'Element': 3 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
args[2] = conversions["DOMString"](args[2]);
return this[impl].setAttributeNS.apply(this[impl], args);
};
Element.prototype.removeAttribute = function removeAttribute(qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'removeAttribute' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].removeAttribute.apply(this[impl], args);
};
Element.prototype.removeAttributeNS = function removeAttributeNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'removeAttributeNS' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return this[impl].removeAttributeNS.apply(this[impl], args);
};
Element.prototype.hasAttribute = function hasAttribute(qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'hasAttribute' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].hasAttribute.apply(this[impl], args);
};
Element.prototype.hasAttributeNS = function hasAttributeNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'hasAttributeNS' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return this[impl].hasAttributeNS.apply(this[impl], args);
};
Element.prototype.getAttributeNode = function getAttributeNode(qualifiedName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getAttributeNode' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getAttributeNode.apply(this[impl], args));
};
Element.prototype.getAttributeNodeNS = function getAttributeNodeNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'getAttributeNodeNS' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].getAttributeNodeNS.apply(this[impl], args));
};
Element.prototype.setAttributeNode = function setAttributeNode(attr) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'setAttributeNode' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].setAttributeNode.apply(this[impl], args));
};
Element.prototype.setAttributeNodeNS = function setAttributeNodeNS(attr) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'setAttributeNodeNS' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].setAttributeNodeNS.apply(this[impl], args));
};
Element.prototype.removeAttributeNode = function removeAttributeNode(attr) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'removeAttributeNode' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].removeAttributeNode.apply(this[impl], args));
};
Element.prototype.matches = function matches(selectors) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'matches' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].matches.apply(this[impl], args);
};
Element.prototype.webkitMatchesSelector = function webkitMatchesSelector(selectors) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'webkitMatchesSelector' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].webkitMatchesSelector.apply(this[impl], args);
};
Element.prototype.getElementsByTagName = function getElementsByTagName(localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementsByTagName' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementsByTagName.apply(this[impl], args));
};
Element.prototype.getElementsByTagNameNS = function getElementsByTagNameNS(namespace, localName) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'getElementsByTagNameNS' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] === null || args[0] === undefined) {
args[0] = null;
} else {
args[0] = conversions["DOMString"](args[0]);
}
args[1] = conversions["DOMString"](args[1]);
return utils.tryWrapperForImpl(this[impl].getElementsByTagNameNS.apply(this[impl], args));
};
Element.prototype.getElementsByClassName = function getElementsByClassName(classNames) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getElementsByClassName' on 'Element': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getElementsByClassName.apply(this[impl], args));
};
Element.prototype.insertAdjacentHTML = function insertAdjacentHTML(position, text) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'insertAdjacentHTML' on 'Element': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["DOMString"](args[1]);
return this[impl].insertAdjacentHTML.apply(this[impl], args);
};
Element.prototype.getClientRects = function getClientRects() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].getClientRects.apply(this[impl], args));
};
Element.prototype.getBoundingClientRect = function getBoundingClientRect() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].getBoundingClientRect.apply(this[impl], args));
};
Element.prototype.toString = function () {
if (this === Element.prototype) {
return "[object ElementPrototype]";
}
return Node.interface.prototype.toString.call(this);
};
Object.defineProperty(Element.prototype, "namespaceURI", {
get() {
return this[impl].namespaceURI;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "prefix", {
get() {
return this[impl].prefix;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "localName", {
get() {
return this[impl].localName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "tagName", {
get() {
return this[impl].tagName;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "id", {
get() {
const value = this.getAttribute("id");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("id", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "className", {
get() {
const value = this.getAttribute("class");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("class", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "classList", {
get() {
return utils.tryWrapperForImpl(this[impl].classList);
},
set(V) {
this.classList.value = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "attributes", {
get() {
return utils.tryWrapperForImpl(this[impl].attributes);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "innerHTML", {
get() {
return this[impl].innerHTML;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].innerHTML = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "outerHTML", {
get() {
return this[impl].outerHTML;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].outerHTML = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "scrollTop", {
get() {
return this[impl].scrollTop;
},
set(V) {
V = conversions["unrestricted double"](V);
this[impl].scrollTop = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "scrollLeft", {
get() {
return this[impl].scrollLeft;
},
set(V) {
V = conversions["unrestricted double"](V);
this[impl].scrollLeft = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "scrollWidth", {
get() {
return this[impl].scrollWidth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "scrollHeight", {
get() {
return this[impl].scrollHeight;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "clientTop", {
get() {
return this[impl].clientTop;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "clientLeft", {
get() {
return this[impl].clientLeft;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "clientWidth", {
get() {
return this[impl].clientWidth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Element.prototype, "clientHeight", {
get() {
return this[impl].clientHeight;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Element.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Element.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Node._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Element,
expose: {
Window: { Element: Element }
}
};
module.exports = iface;
const Impl = require("../nodes/Element-impl.js");

View File

@@ -0,0 +1,88 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function ElementCSSInlineStyle() {
throw new TypeError("Illegal constructor");
}
ElementCSSInlineStyle.prototype.toString = function () {
if (this === ElementCSSInlineStyle.prototype) {
return "[object ElementCSSInlineStylePrototype]";
}
return this[impl].toString();
};
Object.defineProperty(ElementCSSInlineStyle.prototype, "style", {
get() {
return utils.tryWrapperForImpl(this[impl].style);
},
set(V) {
this.style.cssText = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ElementCSSInlineStyle.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ElementCSSInlineStyle.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ElementCSSInlineStyle,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/ElementCSSInlineStyle-impl.js");

View File

@@ -0,0 +1,77 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function ElementContentEditable() {
throw new TypeError("Illegal constructor");
}
ElementContentEditable.prototype.toString = function () {
if (this === ElementContentEditable.prototype) {
return "[object ElementContentEditablePrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ElementContentEditable.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ElementContentEditable.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ElementContentEditable,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/ElementContentEditable-impl.js");

View File

@@ -0,0 +1,137 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Event = require("./Event.js");
const impl = utils.implSymbol;
const convertErrorEventInit = require("./ErrorEventInit").convert;
function ErrorEvent(type) {
if (!this || this[impl] || !(this instanceof ErrorEvent)) {
throw new TypeError("Failed to construct 'ErrorEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'ErrorEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertErrorEventInit(args[1]);
iface.setup(this, args);
}
ErrorEvent.prototype = Object.create(Event.interface.prototype);
ErrorEvent.prototype.constructor = ErrorEvent;
ErrorEvent.prototype.toString = function () {
if (this === ErrorEvent.prototype) {
return "[object ErrorEventPrototype]";
}
return Event.interface.prototype.toString.call(this);
};
Object.defineProperty(ErrorEvent.prototype, "message", {
get() {
return this[impl].message;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorEvent.prototype, "filename", {
get() {
return this[impl].filename;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorEvent.prototype, "lineno", {
get() {
return this[impl].lineno;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorEvent.prototype, "colno", {
get() {
return this[impl].colno;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ErrorEvent.prototype, "error", {
get() {
return this[impl].error;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(ErrorEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(ErrorEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Event._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: ErrorEvent,
expose: {
Window: { ErrorEvent: ErrorEvent },
Worker: { ErrorEvent: ErrorEvent }
}
};
module.exports = iface;
const Impl = require("../events/ErrorEvent-impl.js");

View File

@@ -0,0 +1,56 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventInit = require("./EventInit");
module.exports = {
convertInherit(obj, ret) {
EventInit.convertInherit(obj, ret);
let key, value;
key = "colno";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned long"](value);
}
key = "error";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["any"](value);
}
key = "filename";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
}
key = "lineno";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["unsigned long"](value);
}
key = "message";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["DOMString"](value);
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};

View File

@@ -0,0 +1,263 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
const convertEventInit = require("./EventInit").convert;
function Event(type) {
if (!this || this[impl] || !(this instanceof Event)) {
throw new TypeError("Failed to construct 'Event': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'Event': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertEventInit(args[1]);
iface.setup(this, args);
}
Event.prototype.stopPropagation = function stopPropagation() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].stopPropagation.apply(this[impl], args);
};
Event.prototype.stopImmediatePropagation = function stopImmediatePropagation() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].stopImmediatePropagation.apply(this[impl], args);
};
Event.prototype.preventDefault = function preventDefault() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].preventDefault.apply(this[impl], args);
};
Event.prototype.initEvent = function initEvent(type, bubbles, cancelable) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 3) {
throw new TypeError("Failed to execute 'initEvent' on 'Event': 3 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = conversions["boolean"](args[1]);
args[2] = conversions["boolean"](args[2]);
return this[impl].initEvent.apply(this[impl], args);
};
Event.prototype.toString = function () {
if (this === Event.prototype) {
return "[object EventPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(Event.prototype, "type", {
get() {
return this[impl].type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "target", {
get() {
return utils.tryWrapperForImpl(this[impl].target);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "currentTarget", {
get() {
return utils.tryWrapperForImpl(this[impl].currentTarget);
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event, "NONE", {
value: 0,
enumerable: true
});
Object.defineProperty(Event.prototype, "NONE", {
value: 0,
enumerable: true
});
Object.defineProperty(Event, "CAPTURING_PHASE", {
value: 1,
enumerable: true
});
Object.defineProperty(Event.prototype, "CAPTURING_PHASE", {
value: 1,
enumerable: true
});
Object.defineProperty(Event, "AT_TARGET", {
value: 2,
enumerable: true
});
Object.defineProperty(Event.prototype, "AT_TARGET", {
value: 2,
enumerable: true
});
Object.defineProperty(Event, "BUBBLING_PHASE", {
value: 3,
enumerable: true
});
Object.defineProperty(Event.prototype, "BUBBLING_PHASE", {
value: 3,
enumerable: true
});
Object.defineProperty(Event.prototype, "eventPhase", {
get() {
return this[impl].eventPhase;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "cancelBubble", {
get() {
return this[impl].cancelBubble;
},
set(V) {
V = conversions["boolean"](V);
this[impl].cancelBubble = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "bubbles", {
get() {
return this[impl].bubbles;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "cancelable", {
get() {
return this[impl].cancelable;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "defaultPrevented", {
get() {
return this[impl].defaultPrevented;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "timeStamp", {
get() {
return this[impl].timeStamp;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(Event.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(Event.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Object.defineProperty(obj, "isTrusted", {
get() {
return obj[impl].isTrusted;
},
enumerable: true,
configurable: false
});
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: Event,
expose: {
Window: { Event: Event },
Worker: { Event: Event }
}
};
module.exports = iface;
const Impl = require("../events/Event-impl.js");

View File

@@ -0,0 +1,40 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
module.exports = {
convertInherit(obj, ret) {
let key, value;
key = "bubbles";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "cancelable";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};

View File

@@ -0,0 +1,32 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
module.exports = {
convertInherit(obj, ret) {
let key, value;
key = "capture";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};

View File

@@ -0,0 +1,146 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEventInit = require("./UIEventInit");
module.exports = {
convertInherit(obj, ret) {
UIEventInit.convertInherit(obj, ret);
let key, value;
key = "altKey";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "ctrlKey";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "metaKey";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierAltGraph";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierCapsLock";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierFn";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierFnLock";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierHyper";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierNumLock";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierOS";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierScrollLock";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierSuper";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierSymbol";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "modifierSymbolLock";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
key = "shiftKey";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["boolean"](value);
} else {
ret[key] = false;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};

View File

@@ -0,0 +1,130 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function EventTarget() {
throw new TypeError("Illegal constructor");
}
EventTarget.prototype.addEventListener = function addEventListener(type, callback) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'addEventListener' on 'EventTarget': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
if (args[1] === null || args[1] === undefined) {
args[1] = null;
} else {
}
return this[impl].addEventListener.apply(this[impl], args);
};
EventTarget.prototype.removeEventListener = function removeEventListener(type, callback) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'removeEventListener' on 'EventTarget': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
if (args[1] === null || args[1] === undefined) {
args[1] = null;
} else {
}
return this[impl].removeEventListener.apply(this[impl], args);
};
EventTarget.prototype.dispatchEvent = function dispatchEvent(event) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'dispatchEvent' on 'EventTarget': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].dispatchEvent.apply(this[impl], args);
};
EventTarget.prototype.toString = function () {
if (this === EventTarget.prototype) {
return "[object EventTargetPrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(EventTarget.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(EventTarget.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: EventTarget,
expose: {
Window: { EventTarget: EventTarget },
Worker: { EventTarget: EventTarget }
}
};
module.exports = iface;
const Impl = require("../events/EventTarget-impl.js");

View File

@@ -0,0 +1,113 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Blob = require("./Blob.js");
const impl = utils.implSymbol;
const convertFilePropertyBag = require("./FilePropertyBag").convert;
function File(fileBits, fileName) {
if (!this || this[impl] || !(this instanceof File)) {
throw new TypeError("Failed to construct 'File': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 2) {
throw new TypeError("Failed to construct 'File': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[1] = conversions["USVString"](args[1]);
args[2] = convertFilePropertyBag(args[2]);
iface.setup(this, args);
}
File.prototype = Object.create(Blob.interface.prototype);
File.prototype.constructor = File;
File.prototype.toString = function () {
if (this === File.prototype) {
return "[object FilePrototype]";
}
return Blob.interface.prototype.toString.call(this);
};
Object.defineProperty(File.prototype, "name", {
get() {
return this[impl].name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(File.prototype, "lastModified", {
get() {
return this[impl].lastModified;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(File.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(File.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Blob._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: File,
expose: {
Window: { File: File },
Worker: { File: File }
}
};
module.exports = iface;
const Impl = require("../file-api/File-impl.js");

View File

@@ -0,0 +1,101 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function FileList() {
throw new TypeError("Illegal constructor");
}
FileList.prototype.item = function item(index) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'item' on 'FileList': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
return utils.tryWrapperForImpl(this[impl].item.apply(this[impl], args));
};
FileList.prototype.toString = function () {
if (this === FileList.prototype) {
return "[object FileListPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(FileList.prototype, "length", {
get() {
return this[impl].length;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(FileList.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(FileList.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: FileList,
expose: {
Window: { FileList: FileList },
Worker: { FileList: FileList }
}
};
module.exports = iface;
const Impl = require("../file-api/FileList-impl.js");

View File

@@ -0,0 +1,32 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const BlobPropertyBag = require("./BlobPropertyBag");
module.exports = {
convertInherit(obj, ret) {
BlobPropertyBag.convertInherit(obj, ret);
let key, value;
key = "lastModified";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = conversions["long long"](value);
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};

View File

@@ -0,0 +1,273 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const EventTarget = require("./EventTarget.js");
const impl = utils.implSymbol;
module.exports = {
createInterface: function (defaultPrivateData) {
defaultPrivateData = defaultPrivateData === undefined ? {} : defaultPrivateData;
function FileReader() {
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
iface.setup(this, args);
}
FileReader.prototype = Object.create(EventTarget.interface.prototype);
FileReader.prototype.constructor = FileReader;
FileReader.prototype.readAsArrayBuffer = function readAsArrayBuffer(blob) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'readAsArrayBuffer' on 'FileReader': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].readAsArrayBuffer.apply(this[impl], args);
};
FileReader.prototype.readAsText = function readAsText(blob) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'readAsText' on 'FileReader': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] !== undefined) {
args[1] = conversions["DOMString"](args[1]);
}
return this[impl].readAsText.apply(this[impl], args);
};
FileReader.prototype.readAsDataURL = function readAsDataURL(blob) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'readAsDataURL' on 'FileReader': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].readAsDataURL.apply(this[impl], args);
};
FileReader.prototype.abort = function abort() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].abort.apply(this[impl], args);
};
FileReader.prototype.toString = function () {
if (this === FileReader.prototype) {
return "[object FileReaderPrototype]";
}
return EventTarget.interface.prototype.toString.call(this);
};
Object.defineProperty(FileReader, "EMPTY", {
value: 0,
enumerable: true
});
Object.defineProperty(FileReader.prototype, "EMPTY", {
value: 0,
enumerable: true
});
Object.defineProperty(FileReader, "LOADING", {
value: 1,
enumerable: true
});
Object.defineProperty(FileReader.prototype, "LOADING", {
value: 1,
enumerable: true
});
Object.defineProperty(FileReader, "DONE", {
value: 2,
enumerable: true
});
Object.defineProperty(FileReader.prototype, "DONE", {
value: 2,
enumerable: true
});
Object.defineProperty(FileReader.prototype, "readyState", {
get() {
return this[impl].readyState;
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "result", {
get() {
return utils.tryWrapperForImpl(this[impl].result);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "error", {
get() {
return utils.tryWrapperForImpl(this[impl].error);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onloadstart", {
get() {
return utils.tryWrapperForImpl(this[impl].onloadstart);
},
set(V) {
this[impl].onloadstart = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onprogress", {
get() {
return utils.tryWrapperForImpl(this[impl].onprogress);
},
set(V) {
this[impl].onprogress = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onload", {
get() {
return utils.tryWrapperForImpl(this[impl].onload);
},
set(V) {
this[impl].onload = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onabort", {
get() {
return utils.tryWrapperForImpl(this[impl].onabort);
},
set(V) {
this[impl].onabort = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onerror", {
get() {
return utils.tryWrapperForImpl(this[impl].onerror);
},
set(V) {
this[impl].onerror = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(FileReader.prototype, "onloadend", {
get() {
return utils.tryWrapperForImpl(this[impl].onloadend);
},
set(V) {
this[impl].onloadend = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
const iface = {
create(constructorArgs, privateData) {
let obj = Object.create(FileReader.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(FileReader.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
EventTarget._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
for (var prop in defaultPrivateData) {
if (!(prop in privateData)) {
privateData[prop] = defaultPrivateData[prop];
}
}
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: FileReader,
expose: {
Window: { FileReader: FileReader },
Worker: { FileReader: FileReader }
}
};
return iface;
},
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
};
const Impl = require("../file-api/FileReader-impl.js");

View File

@@ -0,0 +1,104 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEvent = require("./UIEvent.js");
const impl = utils.implSymbol;
const convertFocusEventInit = require("./FocusEventInit").convert;
function FocusEvent(type) {
if (!this || this[impl] || !(this instanceof FocusEvent)) {
throw new TypeError("Failed to construct 'FocusEvent': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
if (arguments.length < 1) {
throw new TypeError("Failed to construct 'FocusEvent': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 2; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
args[1] = convertFocusEventInit(args[1]);
iface.setup(this, args);
}
FocusEvent.prototype = Object.create(UIEvent.interface.prototype);
FocusEvent.prototype.constructor = FocusEvent;
FocusEvent.prototype.toString = function () {
if (this === FocusEvent.prototype) {
return "[object FocusEventPrototype]";
}
return UIEvent.interface.prototype.toString.call(this);
};
Object.defineProperty(FocusEvent.prototype, "relatedTarget", {
get() {
return utils.tryWrapperForImpl(this[impl].relatedTarget);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(FocusEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(FocusEvent.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
UIEvent._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: FocusEvent,
expose: {
Window: { FocusEvent: FocusEvent }
}
};
module.exports = iface;
const Impl = require("../events/FocusEvent-impl.js");

View File

@@ -0,0 +1,34 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const UIEventInit = require("./UIEventInit");
module.exports = {
convertInherit(obj, ret) {
UIEventInit.convertInherit(obj, ret);
let key, value;
key = "relatedTarget";
value = obj === undefined || obj === null ? undefined : obj[key];
if (value !== undefined) {
ret[key] = (value);
} else {
ret[key] = null;
}
},
convert(obj) {
if (obj !== undefined && typeof obj !== "object") {
throw new TypeError("Dictionary has to be an object");
}
if (obj instanceof Date || obj instanceof RegExp) {
throw new TypeError("Dictionary may not be a Date or RegExp object");
}
const ret = Object.create(null);
module.exports.convertInherit(obj, ret);
return ret;
}
};

View File

@@ -0,0 +1,179 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function FormData() {
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
iface.setup(this, args);
}
FormData.prototype.append = function append(name, value) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'append' on 'FormData': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
if (args[2] !== undefined) {
args[2] = conversions["USVString"](args[2]);
}
return this[impl].append.apply(this[impl], args);
};
FormData.prototype.delete = function _(name) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'delete' on 'FormData': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
return this[impl].delete.apply(this[impl], args);
};
FormData.prototype.get = function get(name) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'get' on 'FormData': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
return utils.tryWrapperForImpl(this[impl].get.apply(this[impl], args));
};
FormData.prototype.getAll = function getAll(name) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getAll' on 'FormData': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
return utils.tryWrapperForImpl(this[impl].getAll.apply(this[impl], args));
};
FormData.prototype.has = function has(name) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'has' on 'FormData': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
return this[impl].has.apply(this[impl], args);
};
FormData.prototype.set = function set(name, value) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'set' on 'FormData': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["USVString"](args[0]);
if (args[2] !== undefined) {
args[2] = conversions["USVString"](args[2]);
}
return this[impl].set.apply(this[impl], args);
};
FormData.prototype.toString = function () {
if (this === FormData.prototype) {
return "[object FormDataPrototype]";
}
return this[impl].toString();
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(FormData.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(FormData.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: FormData,
expose: {
Window: { FormData: FormData },
Worker: { FormData: FormData }
}
};
module.exports = iface;
const Impl = require("../xhr/FormData-impl.js");

View File

@@ -0,0 +1,770 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function GlobalEventHandlers() {
throw new TypeError("Illegal constructor");
}
GlobalEventHandlers.prototype.toString = function () {
if (this === GlobalEventHandlers.prototype) {
return "[object GlobalEventHandlersPrototype]";
}
return this[impl].toString();
};
Object.defineProperty(GlobalEventHandlers.prototype, "onabort", {
get() {
return utils.tryWrapperForImpl(this[impl].onabort);
},
set(V) {
this[impl].onabort = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onautocomplete", {
get() {
return utils.tryWrapperForImpl(this[impl].onautocomplete);
},
set(V) {
this[impl].onautocomplete = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onautocompleteerror", {
get() {
return utils.tryWrapperForImpl(this[impl].onautocompleteerror);
},
set(V) {
this[impl].onautocompleteerror = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onblur", {
get() {
return utils.tryWrapperForImpl(this[impl].onblur);
},
set(V) {
this[impl].onblur = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oncancel", {
get() {
return utils.tryWrapperForImpl(this[impl].oncancel);
},
set(V) {
this[impl].oncancel = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oncanplay", {
get() {
return utils.tryWrapperForImpl(this[impl].oncanplay);
},
set(V) {
this[impl].oncanplay = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oncanplaythrough", {
get() {
return utils.tryWrapperForImpl(this[impl].oncanplaythrough);
},
set(V) {
this[impl].oncanplaythrough = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onchange", {
get() {
return utils.tryWrapperForImpl(this[impl].onchange);
},
set(V) {
this[impl].onchange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onclick", {
get() {
return utils.tryWrapperForImpl(this[impl].onclick);
},
set(V) {
this[impl].onclick = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onclose", {
get() {
return utils.tryWrapperForImpl(this[impl].onclose);
},
set(V) {
this[impl].onclose = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oncontextmenu", {
get() {
return utils.tryWrapperForImpl(this[impl].oncontextmenu);
},
set(V) {
this[impl].oncontextmenu = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oncuechange", {
get() {
return utils.tryWrapperForImpl(this[impl].oncuechange);
},
set(V) {
this[impl].oncuechange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondblclick", {
get() {
return utils.tryWrapperForImpl(this[impl].ondblclick);
},
set(V) {
this[impl].ondblclick = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondrag", {
get() {
return utils.tryWrapperForImpl(this[impl].ondrag);
},
set(V) {
this[impl].ondrag = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragend", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragend);
},
set(V) {
this[impl].ondragend = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragenter", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragenter);
},
set(V) {
this[impl].ondragenter = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragexit", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragexit);
},
set(V) {
this[impl].ondragexit = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragleave", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragleave);
},
set(V) {
this[impl].ondragleave = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragover", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragover);
},
set(V) {
this[impl].ondragover = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondragstart", {
get() {
return utils.tryWrapperForImpl(this[impl].ondragstart);
},
set(V) {
this[impl].ondragstart = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondrop", {
get() {
return utils.tryWrapperForImpl(this[impl].ondrop);
},
set(V) {
this[impl].ondrop = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ondurationchange", {
get() {
return utils.tryWrapperForImpl(this[impl].ondurationchange);
},
set(V) {
this[impl].ondurationchange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onemptied", {
get() {
return utils.tryWrapperForImpl(this[impl].onemptied);
},
set(V) {
this[impl].onemptied = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onended", {
get() {
return utils.tryWrapperForImpl(this[impl].onended);
},
set(V) {
this[impl].onended = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onerror", {
get() {
return utils.tryWrapperForImpl(this[impl].onerror);
},
set(V) {
this[impl].onerror = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onfocus", {
get() {
return utils.tryWrapperForImpl(this[impl].onfocus);
},
set(V) {
this[impl].onfocus = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oninput", {
get() {
return utils.tryWrapperForImpl(this[impl].oninput);
},
set(V) {
this[impl].oninput = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "oninvalid", {
get() {
return utils.tryWrapperForImpl(this[impl].oninvalid);
},
set(V) {
this[impl].oninvalid = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onkeydown", {
get() {
return utils.tryWrapperForImpl(this[impl].onkeydown);
},
set(V) {
this[impl].onkeydown = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onkeypress", {
get() {
return utils.tryWrapperForImpl(this[impl].onkeypress);
},
set(V) {
this[impl].onkeypress = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onkeyup", {
get() {
return utils.tryWrapperForImpl(this[impl].onkeyup);
},
set(V) {
this[impl].onkeyup = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onload", {
get() {
return utils.tryWrapperForImpl(this[impl].onload);
},
set(V) {
this[impl].onload = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onloadeddata", {
get() {
return utils.tryWrapperForImpl(this[impl].onloadeddata);
},
set(V) {
this[impl].onloadeddata = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onloadedmetadata", {
get() {
return utils.tryWrapperForImpl(this[impl].onloadedmetadata);
},
set(V) {
this[impl].onloadedmetadata = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onloadstart", {
get() {
return utils.tryWrapperForImpl(this[impl].onloadstart);
},
set(V) {
this[impl].onloadstart = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmousedown", {
get() {
return utils.tryWrapperForImpl(this[impl].onmousedown);
},
set(V) {
this[impl].onmousedown = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmouseenter", {
get() {
return utils.tryWrapperForImpl(this[impl].onmouseenter);
},
set(V) {
this[impl].onmouseenter = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmouseleave", {
get() {
return utils.tryWrapperForImpl(this[impl].onmouseleave);
},
set(V) {
this[impl].onmouseleave = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmousemove", {
get() {
return utils.tryWrapperForImpl(this[impl].onmousemove);
},
set(V) {
this[impl].onmousemove = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmouseout", {
get() {
return utils.tryWrapperForImpl(this[impl].onmouseout);
},
set(V) {
this[impl].onmouseout = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmouseover", {
get() {
return utils.tryWrapperForImpl(this[impl].onmouseover);
},
set(V) {
this[impl].onmouseover = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onmouseup", {
get() {
return utils.tryWrapperForImpl(this[impl].onmouseup);
},
set(V) {
this[impl].onmouseup = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onwheel", {
get() {
return utils.tryWrapperForImpl(this[impl].onwheel);
},
set(V) {
this[impl].onwheel = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onpause", {
get() {
return utils.tryWrapperForImpl(this[impl].onpause);
},
set(V) {
this[impl].onpause = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onplay", {
get() {
return utils.tryWrapperForImpl(this[impl].onplay);
},
set(V) {
this[impl].onplay = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onplaying", {
get() {
return utils.tryWrapperForImpl(this[impl].onplaying);
},
set(V) {
this[impl].onplaying = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onprogress", {
get() {
return utils.tryWrapperForImpl(this[impl].onprogress);
},
set(V) {
this[impl].onprogress = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onratechange", {
get() {
return utils.tryWrapperForImpl(this[impl].onratechange);
},
set(V) {
this[impl].onratechange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onreset", {
get() {
return utils.tryWrapperForImpl(this[impl].onreset);
},
set(V) {
this[impl].onreset = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onresize", {
get() {
return utils.tryWrapperForImpl(this[impl].onresize);
},
set(V) {
this[impl].onresize = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onscroll", {
get() {
return utils.tryWrapperForImpl(this[impl].onscroll);
},
set(V) {
this[impl].onscroll = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onseeked", {
get() {
return utils.tryWrapperForImpl(this[impl].onseeked);
},
set(V) {
this[impl].onseeked = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onseeking", {
get() {
return utils.tryWrapperForImpl(this[impl].onseeking);
},
set(V) {
this[impl].onseeking = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onselect", {
get() {
return utils.tryWrapperForImpl(this[impl].onselect);
},
set(V) {
this[impl].onselect = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onshow", {
get() {
return utils.tryWrapperForImpl(this[impl].onshow);
},
set(V) {
this[impl].onshow = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onsort", {
get() {
return utils.tryWrapperForImpl(this[impl].onsort);
},
set(V) {
this[impl].onsort = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onstalled", {
get() {
return utils.tryWrapperForImpl(this[impl].onstalled);
},
set(V) {
this[impl].onstalled = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onsubmit", {
get() {
return utils.tryWrapperForImpl(this[impl].onsubmit);
},
set(V) {
this[impl].onsubmit = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onsuspend", {
get() {
return utils.tryWrapperForImpl(this[impl].onsuspend);
},
set(V) {
this[impl].onsuspend = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ontimeupdate", {
get() {
return utils.tryWrapperForImpl(this[impl].ontimeupdate);
},
set(V) {
this[impl].ontimeupdate = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "ontoggle", {
get() {
return utils.tryWrapperForImpl(this[impl].ontoggle);
},
set(V) {
this[impl].ontoggle = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onvolumechange", {
get() {
return utils.tryWrapperForImpl(this[impl].onvolumechange);
},
set(V) {
this[impl].onvolumechange = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(GlobalEventHandlers.prototype, "onwaiting", {
get() {
return utils.tryWrapperForImpl(this[impl].onwaiting);
},
set(V) {
this[impl].onwaiting = utils.tryImplForWrapper(V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(GlobalEventHandlers.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(GlobalEventHandlers.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: GlobalEventHandlers,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/GlobalEventHandlers-impl.js");

View File

@@ -0,0 +1,228 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const HTMLHyperlinkElementUtils = require("./HTMLHyperlinkElementUtils.js");
function HTMLAnchorElement() {
throw new TypeError("Illegal constructor");
}
HTMLAnchorElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLAnchorElement.prototype.constructor = HTMLAnchorElement;
mixin(HTMLAnchorElement.prototype, HTMLHyperlinkElementUtils.interface.prototype);
HTMLHyperlinkElementUtils.mixedInto.push(HTMLAnchorElement);
HTMLAnchorElement.prototype.toString = function () {
if (this === HTMLAnchorElement.prototype) {
return "[object HTMLAnchorElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLAnchorElement.prototype, "target", {
get() {
const value = this.getAttribute("target");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("target", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "download", {
get() {
const value = this.getAttribute("download");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("download", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "rel", {
get() {
const value = this.getAttribute("rel");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rel", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "hreflang", {
get() {
const value = this.getAttribute("hreflang");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("hreflang", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "text", {
get() {
return this[impl].text;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].text = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "coords", {
get() {
const value = this.getAttribute("coords");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("coords", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "charset", {
get() {
const value = this.getAttribute("charset");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("charset", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "rev", {
get() {
const value = this.getAttribute("rev");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rev", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAnchorElement.prototype, "shape", {
get() {
const value = this.getAttribute("shape");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("shape", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLAnchorElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLAnchorElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLAnchorElement,
expose: {
Window: { HTMLAnchorElement: HTMLAnchorElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLAnchorElement-impl.js");

View File

@@ -0,0 +1,225 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLAppletElement() {
throw new TypeError("Illegal constructor");
}
HTMLAppletElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLAppletElement.prototype.constructor = HTMLAppletElement;
HTMLAppletElement.prototype.toString = function () {
if (this === HTMLAppletElement.prototype) {
return "[object HTMLAppletElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLAppletElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "alt", {
get() {
const value = this.getAttribute("alt");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("alt", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "archive", {
get() {
const value = this.getAttribute("archive");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("archive", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "code", {
get() {
const value = this.getAttribute("code");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("code", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "codeBase", {
get() {
return this[impl].codeBase;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].codeBase = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "height", {
get() {
const value = this.getAttribute("height");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("height", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "hspace", {
get() {
const value = parseInt(this.getAttribute("hspace"));
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["unsigned long"](V);
V = V > 2147483647 ? 0 : V;
this.setAttribute("hspace", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "object", {
get() {
return this[impl].object;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].object = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "vspace", {
get() {
const value = parseInt(this.getAttribute("vspace"));
return isNaN(value) || value < 0 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["unsigned long"](V);
V = V > 2147483647 ? 0 : V;
this.setAttribute("vspace", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAppletElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLAppletElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLAppletElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLAppletElement,
expose: {
Window: { HTMLAppletElement: HTMLAppletElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLAppletElement-impl.js");

View File

@@ -0,0 +1,167 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const HTMLHyperlinkElementUtils = require("./HTMLHyperlinkElementUtils.js");
function HTMLAreaElement() {
throw new TypeError("Illegal constructor");
}
HTMLAreaElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLAreaElement.prototype.constructor = HTMLAreaElement;
mixin(HTMLAreaElement.prototype, HTMLHyperlinkElementUtils.interface.prototype);
HTMLHyperlinkElementUtils.mixedInto.push(HTMLAreaElement);
HTMLAreaElement.prototype.toString = function () {
if (this === HTMLAreaElement.prototype) {
return "[object HTMLAreaElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLAreaElement.prototype, "alt", {
get() {
const value = this.getAttribute("alt");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("alt", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAreaElement.prototype, "coords", {
get() {
const value = this.getAttribute("coords");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("coords", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAreaElement.prototype, "shape", {
get() {
const value = this.getAttribute("shape");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("shape", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAreaElement.prototype, "target", {
get() {
const value = this.getAttribute("target");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("target", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAreaElement.prototype, "rel", {
get() {
const value = this.getAttribute("rel");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rel", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLAreaElement.prototype, "noHref", {
get() {
return this.hasAttribute("noHref");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("noHref", "");
} else {
this.removeAttribute("noHref");
}
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLAreaElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLAreaElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLAreaElement,
expose: {
Window: { HTMLAreaElement: HTMLAreaElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLAreaElement-impl.js");

View File

@@ -0,0 +1,82 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLMediaElement = require("./HTMLMediaElement.js");
const impl = utils.implSymbol;
function HTMLAudioElement() {
throw new TypeError("Illegal constructor");
}
HTMLAudioElement.prototype = Object.create(HTMLMediaElement.interface.prototype);
HTMLAudioElement.prototype.constructor = HTMLAudioElement;
HTMLAudioElement.prototype.toString = function () {
if (this === HTMLAudioElement.prototype) {
return "[object HTMLAudioElementPrototype]";
}
return HTMLMediaElement.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLAudioElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLAudioElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLMediaElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLAudioElement,
expose: {
Window: { HTMLAudioElement: HTMLAudioElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLAudioElement-impl.js");

View File

@@ -0,0 +1,95 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLBRElement() {
throw new TypeError("Illegal constructor");
}
HTMLBRElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLBRElement.prototype.constructor = HTMLBRElement;
HTMLBRElement.prototype.toString = function () {
if (this === HTMLBRElement.prototype) {
return "[object HTMLBRElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLBRElement.prototype, "clear", {
get() {
const value = this.getAttribute("clear");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("clear", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLBRElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLBRElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLBRElement,
expose: {
Window: { HTMLBRElement: HTMLBRElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLBRElement-impl.js");

View File

@@ -0,0 +1,107 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLBaseElement() {
throw new TypeError("Illegal constructor");
}
HTMLBaseElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLBaseElement.prototype.constructor = HTMLBaseElement;
HTMLBaseElement.prototype.toString = function () {
if (this === HTMLBaseElement.prototype) {
return "[object HTMLBaseElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLBaseElement.prototype, "href", {
get() {
return this[impl].href;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].href = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBaseElement.prototype, "target", {
get() {
const value = this.getAttribute("target");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("target", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLBaseElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLBaseElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLBaseElement,
expose: {
Window: { HTMLBaseElement: HTMLBaseElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLBaseElement-impl.js");

View File

@@ -0,0 +1,164 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const WindowEventHandlers = require("./WindowEventHandlers.js");
function HTMLBodyElement() {
throw new TypeError("Illegal constructor");
}
HTMLBodyElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLBodyElement.prototype.constructor = HTMLBodyElement;
mixin(HTMLBodyElement.prototype, WindowEventHandlers.interface.prototype);
WindowEventHandlers.mixedInto.push(HTMLBodyElement);
HTMLBodyElement.prototype.toString = function () {
if (this === HTMLBodyElement.prototype) {
return "[object HTMLBodyElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLBodyElement.prototype, "text", {
get() {
const value = this.getAttribute("text");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("text", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBodyElement.prototype, "link", {
get() {
const value = this.getAttribute("link");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("link", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBodyElement.prototype, "vLink", {
get() {
const value = this.getAttribute("vLink");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("vLink", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBodyElement.prototype, "aLink", {
get() {
const value = this.getAttribute("aLink");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("aLink", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBodyElement.prototype, "bgColor", {
get() {
const value = this.getAttribute("bgColor");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("bgColor", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLBodyElement.prototype, "background", {
get() {
const value = this.getAttribute("background");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("background", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLBodyElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLBodyElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLBodyElement,
expose: {
Window: { HTMLBodyElement: HTMLBodyElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLBodyElement-impl.js");

View File

@@ -0,0 +1,189 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLButtonElement() {
throw new TypeError("Illegal constructor");
}
HTMLButtonElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLButtonElement.prototype.constructor = HTMLButtonElement;
HTMLButtonElement.prototype.toString = function () {
if (this === HTMLButtonElement.prototype) {
return "[object HTMLButtonElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLButtonElement.prototype, "autofocus", {
get() {
return this.hasAttribute("autofocus");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("autofocus", "");
} else {
this.removeAttribute("autofocus");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "disabled", {
get() {
return this.hasAttribute("disabled");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "formNoValidate", {
get() {
return this.hasAttribute("formNoValidate");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("formNoValidate", "");
} else {
this.removeAttribute("formNoValidate");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "formTarget", {
get() {
const value = this.getAttribute("formTarget");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("formTarget", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "type", {
get() {
return this[impl].type;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].type = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLButtonElement.prototype, "value", {
get() {
const value = this.getAttribute("value");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("value", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLButtonElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLButtonElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLButtonElement,
expose: {
Window: { HTMLButtonElement: HTMLButtonElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLButtonElement-impl.js");

View File

@@ -0,0 +1,193 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLCanvasElement() {
throw new TypeError("Illegal constructor");
}
HTMLCanvasElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLCanvasElement.prototype.constructor = HTMLCanvasElement;
HTMLCanvasElement.prototype.getContext = function getContext(contextId) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'getContext' on 'HTMLCanvasElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
if (args[1] !== undefined) {
args[1] = conversions["any"](args[1]);
}
return utils.tryWrapperForImpl(this[impl].getContext.apply(this[impl], args));
};
HTMLCanvasElement.prototype.probablySupportsContext = function probablySupportsContext(contextId) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'probablySupportsContext' on 'HTMLCanvasElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
if (args[1] !== undefined) {
args[1] = conversions["any"](args[1]);
}
return this[impl].probablySupportsContext.apply(this[impl], args);
};
HTMLCanvasElement.prototype.setContext = function setContext(context) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'setContext' on 'HTMLCanvasElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 1; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].setContext.apply(this[impl], args);
};
HTMLCanvasElement.prototype.toDataURL = function toDataURL() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[0] !== undefined) {
args[0] = conversions["DOMString"](args[0]);
}
if (args[1] !== undefined) {
args[1] = conversions["any"](args[1]);
}
return this[impl].toDataURL.apply(this[impl], args);
};
HTMLCanvasElement.prototype.toBlob = function toBlob(callback) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'toBlob' on 'HTMLCanvasElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
if (args[1] !== undefined) {
args[1] = conversions["DOMString"](args[1]);
}
if (args[2] !== undefined) {
args[2] = conversions["any"](args[2]);
}
return this[impl].toBlob.apply(this[impl], args);
};
HTMLCanvasElement.prototype.toString = function () {
if (this === HTMLCanvasElement.prototype) {
return "[object HTMLCanvasElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLCanvasElement.prototype, "width", {
get() {
return this[impl].width;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].width = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLCanvasElement.prototype, "height", {
get() {
return this[impl].height;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].height = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLCanvasElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLCanvasElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLCanvasElement,
expose: {
Window: { HTMLCanvasElement: HTMLCanvasElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLCanvasElement-impl.js");

View File

@@ -0,0 +1,98 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDListElement() {
throw new TypeError("Illegal constructor");
}
HTMLDListElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDListElement.prototype.constructor = HTMLDListElement;
HTMLDListElement.prototype.toString = function () {
if (this === HTMLDListElement.prototype) {
return "[object HTMLDListElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLDListElement.prototype, "compact", {
get() {
return this.hasAttribute("compact");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("compact", "");
} else {
this.removeAttribute("compact");
}
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDListElement,
expose: {
Window: { HTMLDListElement: HTMLDListElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDListElement-impl.js");

View File

@@ -0,0 +1,95 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDataElement() {
throw new TypeError("Illegal constructor");
}
HTMLDataElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDataElement.prototype.constructor = HTMLDataElement;
HTMLDataElement.prototype.toString = function () {
if (this === HTMLDataElement.prototype) {
return "[object HTMLDataElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLDataElement.prototype, "value", {
get() {
const value = this.getAttribute("value");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("value", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDataElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDataElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDataElement,
expose: {
Window: { HTMLDataElement: HTMLDataElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDataElement-impl.js");

View File

@@ -0,0 +1,82 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDataListElement() {
throw new TypeError("Illegal constructor");
}
HTMLDataListElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDataListElement.prototype.constructor = HTMLDataListElement;
HTMLDataListElement.prototype.toString = function () {
if (this === HTMLDataListElement.prototype) {
return "[object HTMLDataListElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDataListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDataListElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDataListElement,
expose: {
Window: { HTMLDataListElement: HTMLDataListElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDataListElement-impl.js");

View File

@@ -0,0 +1,98 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDialogElement() {
throw new TypeError("Illegal constructor");
}
HTMLDialogElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDialogElement.prototype.constructor = HTMLDialogElement;
HTMLDialogElement.prototype.toString = function () {
if (this === HTMLDialogElement.prototype) {
return "[object HTMLDialogElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLDialogElement.prototype, "open", {
get() {
return this.hasAttribute("open");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("open", "");
} else {
this.removeAttribute("open");
}
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDialogElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDialogElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDialogElement,
expose: {
Window: { HTMLDialogElement: HTMLDialogElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDialogElement-impl.js");

View File

@@ -0,0 +1,98 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDirectoryElement() {
throw new TypeError("Illegal constructor");
}
HTMLDirectoryElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDirectoryElement.prototype.constructor = HTMLDirectoryElement;
HTMLDirectoryElement.prototype.toString = function () {
if (this === HTMLDirectoryElement.prototype) {
return "[object HTMLDirectoryElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLDirectoryElement.prototype, "compact", {
get() {
return this.hasAttribute("compact");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("compact", "");
} else {
this.removeAttribute("compact");
}
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDirectoryElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDirectoryElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDirectoryElement,
expose: {
Window: { HTMLDirectoryElement: HTMLDirectoryElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDirectoryElement-impl.js");

View File

@@ -0,0 +1,95 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLDivElement() {
throw new TypeError("Illegal constructor");
}
HTMLDivElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLDivElement.prototype.constructor = HTMLDivElement;
HTMLDivElement.prototype.toString = function () {
if (this === HTMLDivElement.prototype) {
return "[object HTMLDivElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLDivElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLDivElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLDivElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLDivElement,
expose: {
Window: { HTMLDivElement: HTMLDivElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLDivElement-impl.js");

View File

@@ -0,0 +1,245 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const Element = require("./Element.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const ElementCSSInlineStyle = require("./ElementCSSInlineStyle.js");
const GlobalEventHandlers = require("./GlobalEventHandlers.js");
const ElementContentEditable = require("./ElementContentEditable.js");
function HTMLElement() {
throw new TypeError("Illegal constructor");
}
HTMLElement.prototype = Object.create(Element.interface.prototype);
HTMLElement.prototype.constructor = HTMLElement;
mixin(HTMLElement.prototype, ElementCSSInlineStyle.interface.prototype);
ElementCSSInlineStyle.mixedInto.push(HTMLElement);
mixin(HTMLElement.prototype, GlobalEventHandlers.interface.prototype);
GlobalEventHandlers.mixedInto.push(HTMLElement);
mixin(HTMLElement.prototype, ElementContentEditable.interface.prototype);
ElementContentEditable.mixedInto.push(HTMLElement);
HTMLElement.prototype.click = function click() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].click.apply(this[impl], args);
};
HTMLElement.prototype.focus = function focus() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].focus.apply(this[impl], args);
};
HTMLElement.prototype.blur = function blur() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].blur.apply(this[impl], args);
};
HTMLElement.prototype.toString = function () {
if (this === HTMLElement.prototype) {
return "[object HTMLElementPrototype]";
}
return Element.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLElement.prototype, "title", {
get() {
const value = this.getAttribute("title");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("title", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "lang", {
get() {
const value = this.getAttribute("lang");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("lang", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "dir", {
get() {
const value = this.getAttribute("dir");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("dir", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "hidden", {
get() {
return this.hasAttribute("hidden");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("hidden", "");
} else {
this.removeAttribute("hidden");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "tabIndex", {
get() {
return this[impl].tabIndex;
},
set(V) {
V = conversions["long"](V);
this[impl].tabIndex = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "accessKey", {
get() {
const value = this.getAttribute("accessKey");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("accessKey", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "offsetParent", {
get() {
return utils.tryWrapperForImpl(this[impl].offsetParent);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "offsetTop", {
get() {
return this[impl].offsetTop;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "offsetLeft", {
get() {
return this[impl].offsetLeft;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "offsetWidth", {
get() {
return this[impl].offsetWidth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLElement.prototype, "offsetHeight", {
get() {
return this[impl].offsetHeight;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
Element._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLElement,
expose: {
Window: { HTMLElement: HTMLElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLElement-impl.js");

View File

@@ -0,0 +1,159 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLEmbedElement() {
throw new TypeError("Illegal constructor");
}
HTMLEmbedElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLEmbedElement.prototype.constructor = HTMLEmbedElement;
HTMLEmbedElement.prototype.toString = function () {
if (this === HTMLEmbedElement.prototype) {
return "[object HTMLEmbedElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLEmbedElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLEmbedElement.prototype, "type", {
get() {
const value = this.getAttribute("type");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("type", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLEmbedElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLEmbedElement.prototype, "height", {
get() {
const value = this.getAttribute("height");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("height", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLEmbedElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLEmbedElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLEmbedElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLEmbedElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLEmbedElement,
expose: {
Window: { HTMLEmbedElement: HTMLEmbedElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLEmbedElement-impl.js");

View File

@@ -0,0 +1,119 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLFieldSetElement() {
throw new TypeError("Illegal constructor");
}
HTMLFieldSetElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLFieldSetElement.prototype.constructor = HTMLFieldSetElement;
HTMLFieldSetElement.prototype.toString = function () {
if (this === HTMLFieldSetElement.prototype) {
return "[object HTMLFieldSetElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLFieldSetElement.prototype, "disabled", {
get() {
return this.hasAttribute("disabled");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFieldSetElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFieldSetElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLFieldSetElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLFieldSetElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLFieldSetElement,
expose: {
Window: { HTMLFieldSetElement: HTMLFieldSetElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLFieldSetElement-impl.js");

View File

@@ -0,0 +1,121 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLFontElement() {
throw new TypeError("Illegal constructor");
}
HTMLFontElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLFontElement.prototype.constructor = HTMLFontElement;
HTMLFontElement.prototype.toString = function () {
if (this === HTMLFontElement.prototype) {
return "[object HTMLFontElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLFontElement.prototype, "color", {
get() {
const value = this.getAttribute("color");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("color", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFontElement.prototype, "face", {
get() {
const value = this.getAttribute("face");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("face", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFontElement.prototype, "size", {
get() {
const value = this.getAttribute("size");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("size", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLFontElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLFontElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLFontElement,
expose: {
Window: { HTMLFontElement: HTMLFontElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLFontElement-impl.js");

View File

@@ -0,0 +1,211 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLFormElement() {
throw new TypeError("Illegal constructor");
}
HTMLFormElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLFormElement.prototype.constructor = HTMLFormElement;
HTMLFormElement.prototype.submit = function submit() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].submit.apply(this[impl], args);
};
HTMLFormElement.prototype.reset = function reset() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].reset.apply(this[impl], args);
};
HTMLFormElement.prototype.toString = function () {
if (this === HTMLFormElement.prototype) {
return "[object HTMLFormElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLFormElement.prototype, "acceptCharset", {
get() {
const value = this.getAttribute("accept-charset");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("accept-charset", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "action", {
get() {
return this[impl].action;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].action = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "enctype", {
get() {
return this[impl].enctype;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].enctype = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "method", {
get() {
return this[impl].method;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].method = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "noValidate", {
get() {
return this.hasAttribute("noValidate");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("noValidate", "");
} else {
this.removeAttribute("noValidate");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "target", {
get() {
const value = this.getAttribute("target");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("target", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "elements", {
get() {
return utils.tryWrapperForImpl(this[impl].elements);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFormElement.prototype, "length", {
get() {
return this[impl].length;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLFormElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLFormElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLFormElement,
expose: {
Window: { HTMLFormElement: HTMLFormElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLFormElement-impl.js");

View File

@@ -0,0 +1,203 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLFrameElement() {
throw new TypeError("Illegal constructor");
}
HTMLFrameElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLFrameElement.prototype.constructor = HTMLFrameElement;
HTMLFrameElement.prototype.toString = function () {
if (this === HTMLFrameElement.prototype) {
return "[object HTMLFrameElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLFrameElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "scrolling", {
get() {
const value = this.getAttribute("scrolling");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("scrolling", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "frameBorder", {
get() {
const value = this.getAttribute("frameBorder");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("frameBorder", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "longDesc", {
get() {
return this[impl].longDesc;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].longDesc = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "noResize", {
get() {
return this.hasAttribute("noResize");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("noResize", "");
} else {
this.removeAttribute("noResize");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "contentDocument", {
get() {
return utils.tryWrapperForImpl(this[impl].contentDocument);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "contentWindow", {
get() {
return utils.tryWrapperForImpl(this[impl].contentWindow);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "marginHeight", {
get() {
const value = this.getAttribute("marginHeight");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("marginHeight", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameElement.prototype, "marginWidth", {
get() {
const value = this.getAttribute("marginWidth");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("marginWidth", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLFrameElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLFrameElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLFrameElement,
expose: {
Window: { HTMLFrameElement: HTMLFrameElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLFrameElement-impl.js");

View File

@@ -0,0 +1,112 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
const mixin = utils.mixin;
const WindowEventHandlers = require("./WindowEventHandlers.js");
function HTMLFrameSetElement() {
throw new TypeError("Illegal constructor");
}
HTMLFrameSetElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLFrameSetElement.prototype.constructor = HTMLFrameSetElement;
mixin(HTMLFrameSetElement.prototype, WindowEventHandlers.interface.prototype);
WindowEventHandlers.mixedInto.push(HTMLFrameSetElement);
HTMLFrameSetElement.prototype.toString = function () {
if (this === HTMLFrameSetElement.prototype) {
return "[object HTMLFrameSetElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLFrameSetElement.prototype, "cols", {
get() {
const value = this.getAttribute("cols");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("cols", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLFrameSetElement.prototype, "rows", {
get() {
const value = this.getAttribute("rows");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("rows", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLFrameSetElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLFrameSetElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLFrameSetElement,
expose: {
Window: { HTMLFrameSetElement: HTMLFrameSetElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLFrameSetElement-impl.js");

View File

@@ -0,0 +1,150 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLHRElement() {
throw new TypeError("Illegal constructor");
}
HTMLHRElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLHRElement.prototype.constructor = HTMLHRElement;
HTMLHRElement.prototype.toString = function () {
if (this === HTMLHRElement.prototype) {
return "[object HTMLHRElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLHRElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHRElement.prototype, "color", {
get() {
const value = this.getAttribute("color");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("color", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHRElement.prototype, "noShade", {
get() {
return this.hasAttribute("noShade");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("noShade", "");
} else {
this.removeAttribute("noShade");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHRElement.prototype, "size", {
get() {
const value = this.getAttribute("size");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("size", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHRElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLHRElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLHRElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLHRElement,
expose: {
Window: { HTMLHRElement: HTMLHRElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLHRElement-impl.js");

View File

@@ -0,0 +1,82 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLHeadElement() {
throw new TypeError("Illegal constructor");
}
HTMLHeadElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLHeadElement.prototype.constructor = HTMLHeadElement;
HTMLHeadElement.prototype.toString = function () {
if (this === HTMLHeadElement.prototype) {
return "[object HTMLHeadElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLHeadElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLHeadElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLHeadElement,
expose: {
Window: { HTMLHeadElement: HTMLHeadElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLHeadElement-impl.js");

View File

@@ -0,0 +1,95 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLHeadingElement() {
throw new TypeError("Illegal constructor");
}
HTMLHeadingElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLHeadingElement.prototype.constructor = HTMLHeadingElement;
HTMLHeadingElement.prototype.toString = function () {
if (this === HTMLHeadingElement.prototype) {
return "[object HTMLHeadingElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLHeadingElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLHeadingElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLHeadingElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLHeadingElement,
expose: {
Window: { HTMLHeadingElement: HTMLHeadingElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLHeadingElement-impl.js");

View File

@@ -0,0 +1,95 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLHtmlElement() {
throw new TypeError("Illegal constructor");
}
HTMLHtmlElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLHtmlElement.prototype.constructor = HTMLHtmlElement;
HTMLHtmlElement.prototype.toString = function () {
if (this === HTMLHtmlElement.prototype) {
return "[object HTMLHtmlElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLHtmlElement.prototype, "version", {
get() {
const value = this.getAttribute("version");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("version", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLHtmlElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLHtmlElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLHtmlElement,
expose: {
Window: { HTMLHtmlElement: HTMLHtmlElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLHtmlElement-impl.js");

View File

@@ -0,0 +1,205 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const impl = utils.implSymbol;
function HTMLHyperlinkElementUtils() {
throw new TypeError("Illegal constructor");
}
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "href", {
get() {
return this[impl].href;
},
set(V) {
V = conversions["USVString"](V);
this[impl].href = V;
},
enumerable: true,
configurable: true
});
HTMLHyperlinkElementUtils.prototype.toString = function () {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
return this[impl].href;;
};
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "origin", {
get() {
return this[impl].origin;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "protocol", {
get() {
return this[impl].protocol;
},
set(V) {
V = conversions["USVString"](V);
this[impl].protocol = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "username", {
get() {
return this[impl].username;
},
set(V) {
V = conversions["USVString"](V);
this[impl].username = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "password", {
get() {
return this[impl].password;
},
set(V) {
V = conversions["USVString"](V);
this[impl].password = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "host", {
get() {
return this[impl].host;
},
set(V) {
V = conversions["USVString"](V);
this[impl].host = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "hostname", {
get() {
return this[impl].hostname;
},
set(V) {
V = conversions["USVString"](V);
this[impl].hostname = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "port", {
get() {
return this[impl].port;
},
set(V) {
V = conversions["USVString"](V);
this[impl].port = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "pathname", {
get() {
return this[impl].pathname;
},
set(V) {
V = conversions["USVString"](V);
this[impl].pathname = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "search", {
get() {
return this[impl].search;
},
set(V) {
V = conversions["USVString"](V);
this[impl].search = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLHyperlinkElementUtils.prototype, "hash", {
get() {
return this[impl].hash;
},
set(V) {
V = conversions["USVString"](V);
this[impl].hash = V;
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLHyperlinkElementUtils.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLHyperlinkElementUtils.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLHyperlinkElementUtils,
expose: {
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLHyperlinkElementUtils-impl.js");

View File

@@ -0,0 +1,278 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLIFrameElement() {
throw new TypeError("Illegal constructor");
}
HTMLIFrameElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLIFrameElement.prototype.constructor = HTMLIFrameElement;
HTMLIFrameElement.prototype.getSVGDocument = function getSVGDocument() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return utils.tryWrapperForImpl(this[impl].getSVGDocument.apply(this[impl], args));
};
HTMLIFrameElement.prototype.toString = function () {
if (this === HTMLIFrameElement.prototype) {
return "[object HTMLIFrameElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLIFrameElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "srcdoc", {
get() {
const value = this.getAttribute("srcdoc");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("srcdoc", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "seamless", {
get() {
return this[impl].seamless;
},
set(V) {
V = conversions["boolean"](V);
this[impl].seamless = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "allowFullscreen", {
get() {
return this.hasAttribute("allowFullscreen");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("allowFullscreen", "");
} else {
this.removeAttribute("allowFullscreen");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "width", {
get() {
const value = this.getAttribute("width");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("width", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "height", {
get() {
const value = this.getAttribute("height");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("height", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "contentDocument", {
get() {
return utils.tryWrapperForImpl(this[impl].contentDocument);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "contentWindow", {
get() {
return utils.tryWrapperForImpl(this[impl].contentWindow);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "scrolling", {
get() {
const value = this.getAttribute("scrolling");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("scrolling", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "frameBorder", {
get() {
const value = this.getAttribute("frameBorder");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("frameBorder", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "longDesc", {
get() {
return this[impl].longDesc;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].longDesc = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "marginHeight", {
get() {
const value = this.getAttribute("marginHeight");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("marginHeight", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLIFrameElement.prototype, "marginWidth", {
get() {
const value = this.getAttribute("marginWidth");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("marginWidth", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLIFrameElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLIFrameElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLIFrameElement,
expose: {
Window: { HTMLIFrameElement: HTMLIFrameElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLIFrameElement-impl.js");

View File

@@ -0,0 +1,326 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLImageElement() {
throw new TypeError("Illegal constructor");
}
HTMLImageElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLImageElement.prototype.constructor = HTMLImageElement;
HTMLImageElement.prototype.toString = function () {
if (this === HTMLImageElement.prototype) {
return "[object HTMLImageElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLImageElement.prototype, "alt", {
get() {
const value = this.getAttribute("alt");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("alt", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "src", {
get() {
return this[impl].src;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].src = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "srcset", {
get() {
const value = this.getAttribute("srcset");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("srcset", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "sizes", {
get() {
const value = this.getAttribute("sizes");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("sizes", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "crossOrigin", {
get() {
const value = this.getAttribute("crossOrigin");
return value === null ? "" : value;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["DOMString"](V);
}
this.setAttribute("crossOrigin", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "useMap", {
get() {
const value = this.getAttribute("useMap");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("useMap", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "isMap", {
get() {
return this.hasAttribute("isMap");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("isMap", "");
} else {
this.removeAttribute("isMap");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "width", {
get() {
return this[impl].width;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].width = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "height", {
get() {
return this[impl].height;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].height = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "naturalWidth", {
get() {
return this[impl].naturalWidth;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "naturalHeight", {
get() {
return this[impl].naturalHeight;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "complete", {
get() {
return this[impl].complete;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "currentSrc", {
get() {
return this[impl].currentSrc;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "lowsrc", {
get() {
const value = this.getAttribute("lowsrc");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("lowsrc", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "hspace", {
get() {
const value = parseInt(this.getAttribute("hspace"));
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["long"](V);
this.setAttribute("hspace", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "vspace", {
get() {
const value = parseInt(this.getAttribute("vspace"));
return isNaN(value) || value < -2147483648 || value > 2147483647 ? 0 : value
},
set(V) {
V = conversions["long"](V);
this.setAttribute("vspace", String(V));
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "longDesc", {
get() {
const value = this.getAttribute("longDesc");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("longDesc", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLImageElement.prototype, "border", {
get() {
const value = this.getAttribute("border");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this.setAttribute("border", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLImageElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLImageElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLImageElement,
expose: {
Window: { HTMLImageElement: HTMLImageElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLImageElement-impl.js");

View File

@@ -0,0 +1,583 @@
"use strict";
const conversions = require("webidl-conversions");
const utils = require("./utils.js");
const HTMLElement = require("./HTMLElement.js");
const impl = utils.implSymbol;
function HTMLInputElement() {
throw new TypeError("Illegal constructor");
}
HTMLInputElement.prototype = Object.create(HTMLElement.interface.prototype);
HTMLInputElement.prototype.constructor = HTMLInputElement;
HTMLInputElement.prototype.select = function select() {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
const args = [];
for (let i = 0; i < arguments.length && i < 0; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
return this[impl].select.apply(this[impl], args);
};
HTMLInputElement.prototype.setRangeText = function setRangeText(replacement) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 1) {
throw new TypeError("Failed to execute 'setRangeText' on 'HTMLInputElement': 1 argument required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 4; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["DOMString"](args[0]);
return this[impl].setRangeText.apply(this[impl], args);
};
HTMLInputElement.prototype.setSelectionRange = function setSelectionRange(start, end) {
if (!this || !module.exports.is(this)) {
throw new TypeError("Illegal invocation");
}
if (arguments.length < 2) {
throw new TypeError("Failed to execute 'setSelectionRange' on 'HTMLInputElement': 2 arguments required, but only " + arguments.length + " present.");
}
const args = [];
for (let i = 0; i < arguments.length && i < 3; ++i) {
args[i] = utils.tryImplForWrapper(arguments[i]);
}
args[0] = conversions["unsigned long"](args[0]);
args[1] = conversions["unsigned long"](args[1]);
if (args[2] !== undefined) {
args[2] = conversions["DOMString"](args[2]);
}
return this[impl].setSelectionRange.apply(this[impl], args);
};
HTMLInputElement.prototype.toString = function () {
if (this === HTMLInputElement.prototype) {
return "[object HTMLInputElementPrototype]";
}
return HTMLElement.interface.prototype.toString.call(this);
};
Object.defineProperty(HTMLInputElement.prototype, "accept", {
get() {
const value = this.getAttribute("accept");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("accept", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "alt", {
get() {
const value = this.getAttribute("alt");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("alt", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "autocomplete", {
get() {
const value = this.getAttribute("autocomplete");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("autocomplete", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "autofocus", {
get() {
return this.hasAttribute("autofocus");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("autofocus", "");
} else {
this.removeAttribute("autofocus");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "defaultChecked", {
get() {
return this.hasAttribute("checked");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("checked", "");
} else {
this.removeAttribute("checked");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "checked", {
get() {
return this[impl].checked;
},
set(V) {
V = conversions["boolean"](V);
this[impl].checked = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "dirName", {
get() {
const value = this.getAttribute("dirName");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("dirName", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "disabled", {
get() {
return this.hasAttribute("disabled");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("disabled", "");
} else {
this.removeAttribute("disabled");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "form", {
get() {
return utils.tryWrapperForImpl(this[impl].form);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "files", {
get() {
return utils.tryWrapperForImpl(this[impl].files);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "formNoValidate", {
get() {
return this.hasAttribute("formNoValidate");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("formNoValidate", "");
} else {
this.removeAttribute("formNoValidate");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "formTarget", {
get() {
const value = this.getAttribute("formTarget");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("formTarget", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "inputMode", {
get() {
const value = this.getAttribute("inputMode");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("inputMode", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "max", {
get() {
const value = this.getAttribute("max");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("max", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "maxLength", {
get() {
return this[impl].maxLength;
},
set(V) {
V = conversions["long"](V);
this[impl].maxLength = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "min", {
get() {
const value = this.getAttribute("min");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("min", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "minLength", {
get() {
return this[impl].minLength;
},
set(V) {
V = conversions["long"](V);
this[impl].minLength = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "multiple", {
get() {
return this.hasAttribute("multiple");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("multiple", "");
} else {
this.removeAttribute("multiple");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "name", {
get() {
const value = this.getAttribute("name");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("name", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "pattern", {
get() {
const value = this.getAttribute("pattern");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("pattern", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "placeholder", {
get() {
const value = this.getAttribute("placeholder");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("placeholder", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "readOnly", {
get() {
return this.hasAttribute("readOnly");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("readOnly", "");
} else {
this.removeAttribute("readOnly");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "required", {
get() {
return this.hasAttribute("required");
},
set(V) {
V = conversions["boolean"](V);
if (V) {
this.setAttribute("required", "");
} else {
this.removeAttribute("required");
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "size", {
get() {
return this[impl].size;
},
set(V) {
V = conversions["unsigned long"](V);
this[impl].size = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "src", {
get() {
const value = this.getAttribute("src");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("src", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "step", {
get() {
const value = this.getAttribute("step");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("step", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "type", {
get() {
return this[impl].type;
},
set(V) {
V = conversions["DOMString"](V);
this[impl].type = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "defaultValue", {
get() {
const value = this.getAttribute("value");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("value", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "value", {
get() {
return this[impl].value;
},
set(V) {
V = conversions["DOMString"](V, { treatNullAsEmptyString: true });
this[impl].value = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "selectionStart", {
get() {
return this[impl].selectionStart;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["unsigned long"](V);
}
this[impl].selectionStart = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "selectionEnd", {
get() {
return this[impl].selectionEnd;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["unsigned long"](V);
}
this[impl].selectionEnd = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "selectionDirection", {
get() {
return this[impl].selectionDirection;
},
set(V) {
if (V === null || V === undefined) {
V = null;
} else {
V = conversions["DOMString"](V);
}
this[impl].selectionDirection = V;
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "align", {
get() {
const value = this.getAttribute("align");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("align", V);
},
enumerable: true,
configurable: true
});
Object.defineProperty(HTMLInputElement.prototype, "useMap", {
get() {
const value = this.getAttribute("useMap");
return value === null ? "" : value;
},
set(V) {
V = conversions["DOMString"](V);
this.setAttribute("useMap", V);
},
enumerable: true,
configurable: true
});
const iface = {
mixedInto: [],
is(obj) {
if (obj) {
if (obj[impl] instanceof Impl.implementation) {
return true;
}
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (obj instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
isImpl(obj) {
if (obj) {
if (obj instanceof Impl.implementation) {
return true;
}
const wrapper = utils.wrapperForImpl(obj);
for (let i = 0; i < module.exports.mixedInto.length; ++i) {
if (wrapper instanceof module.exports.mixedInto[i]) {
return true;
}
}
}
return false;
},
create(constructorArgs, privateData) {
let obj = Object.create(HTMLInputElement.prototype);
this.setup(obj, constructorArgs, privateData);
return obj;
},
createImpl(constructorArgs, privateData) {
let obj = Object.create(HTMLInputElement.prototype);
this.setup(obj, constructorArgs, privateData);
return utils.implForWrapper(obj);
},
_internalSetup(obj) {
HTMLElement._internalSetup(obj);
},
setup(obj, constructorArgs, privateData) {
if (!privateData) privateData = {};
privateData.wrapper = obj;
this._internalSetup(obj);
obj[impl] = new Impl.implementation(constructorArgs, privateData);
obj[impl][utils.wrapperSymbol] = obj;
},
interface: HTMLInputElement,
expose: {
Window: { HTMLInputElement: HTMLInputElement }
}
};
module.exports = iface;
const Impl = require("../nodes/HTMLInputElement-impl.js");

Some files were not shown because too many files have changed in this diff Show More