happy-dom 2.43.0 → 2.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of happy-dom might be problematic. Click here for more details.
- package/lib/navigator/MimeType.d.ts +25 -0
- package/lib/navigator/MimeType.js +32 -0
- package/lib/navigator/MimeType.js.map +1 -0
- package/lib/navigator/MimeTypeArray.d.ts +31 -0
- package/lib/navigator/MimeTypeArray.js +45 -0
- package/lib/navigator/MimeTypeArray.js.map +1 -0
- package/lib/navigator/Navigator.d.ts +41 -0
- package/lib/navigator/Navigator.js +78 -0
- package/lib/navigator/Navigator.js.map +1 -0
- package/lib/navigator/Plugin.d.ts +40 -0
- package/lib/navigator/Plugin.js +55 -0
- package/lib/navigator/Plugin.js.map +1 -0
- package/lib/navigator/PluginArray.d.ts +38 -0
- package/lib/navigator/PluginArray.js +54 -0
- package/lib/navigator/PluginArray.js.map +1 -0
- package/lib/query-selector/SelectorItem.d.ts +19 -3
- package/lib/query-selector/SelectorItem.js +55 -27
- package/lib/query-selector/SelectorItem.js.map +1 -1
- package/lib/window/IWindow.d.ts +11 -3
- package/lib/window/Window.d.ts +11 -3
- package/lib/window/Window.js +11 -1
- package/lib/window/Window.js.map +1 -1
- package/package.json +2 -2
- package/src/navigator/MimeType.ts +35 -0
- package/src/navigator/MimeTypeArray.ts +48 -0
- package/src/navigator/Navigator.ts +93 -0
- package/src/navigator/Plugin.ts +61 -0
- package/src/navigator/PluginArray.ts +58 -0
- package/src/query-selector/SelectorItem.ts +62 -28
- package/src/window/IWindow.ts +11 -1
- package/src/window/Window.ts +11 -1
@@ -0,0 +1,25 @@
|
|
1
|
+
import Plugin from './Plugin';
|
2
|
+
/**
|
3
|
+
* MimeType.
|
4
|
+
*/
|
5
|
+
export default class MimeType {
|
6
|
+
readonly description: string;
|
7
|
+
readonly enabledPlugin: Plugin;
|
8
|
+
readonly suffixes: string;
|
9
|
+
readonly type: string;
|
10
|
+
/**
|
11
|
+
* Constructor.
|
12
|
+
*
|
13
|
+
* @param description
|
14
|
+
* @param enabledPlugin
|
15
|
+
* @param suffixes
|
16
|
+
* @param type
|
17
|
+
*/
|
18
|
+
constructor(description: string, enabledPlugin: Plugin, suffixes: string, type: string);
|
19
|
+
/**
|
20
|
+
* Returns the object as a string.
|
21
|
+
*
|
22
|
+
* @returns String.
|
23
|
+
*/
|
24
|
+
toString(): string;
|
25
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/**
|
4
|
+
* MimeType.
|
5
|
+
*/
|
6
|
+
var MimeType = /** @class */ (function () {
|
7
|
+
/**
|
8
|
+
* Constructor.
|
9
|
+
*
|
10
|
+
* @param description
|
11
|
+
* @param enabledPlugin
|
12
|
+
* @param suffixes
|
13
|
+
* @param type
|
14
|
+
*/
|
15
|
+
function MimeType(description, enabledPlugin, suffixes, type) {
|
16
|
+
this.description = description;
|
17
|
+
this.enabledPlugin = enabledPlugin;
|
18
|
+
this.suffixes = suffixes;
|
19
|
+
this.type = type;
|
20
|
+
}
|
21
|
+
/**
|
22
|
+
* Returns the object as a string.
|
23
|
+
*
|
24
|
+
* @returns String.
|
25
|
+
*/
|
26
|
+
MimeType.prototype.toString = function () {
|
27
|
+
return '[object MimeType]';
|
28
|
+
};
|
29
|
+
return MimeType;
|
30
|
+
}());
|
31
|
+
exports.default = MimeType;
|
32
|
+
//# sourceMappingURL=MimeType.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MimeType.js","sourceRoot":"","sources":["../../src/navigator/MimeType.ts"],"names":[],"mappings":";;AAEA;;GAEG;AACH;IAMC;;;;;;;OAOG;IACH,kBAAY,WAAmB,EAAE,aAAqB,EAAE,QAAgB,EAAE,IAAY;QACrF,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACI,2BAAQ,GAAf;QACC,OAAO,mBAAmB,CAAC;IAC5B,CAAC;IACF,eAAC;AAAD,CAAC,AA7BD,IA6BC"}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import MimeType from './MimeType';
|
2
|
+
/**
|
3
|
+
* MimeTypeArray.
|
4
|
+
*
|
5
|
+
* Reference:
|
6
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.
|
7
|
+
*/
|
8
|
+
export default class MimeTypeArray {
|
9
|
+
[n: number]: MimeType;
|
10
|
+
readonly length: number;
|
11
|
+
/**
|
12
|
+
* Constructor.
|
13
|
+
*
|
14
|
+
* @param mimeTypes
|
15
|
+
*/
|
16
|
+
constructor(mimeTypes: MimeType[]);
|
17
|
+
/**
|
18
|
+
* @param index
|
19
|
+
*/
|
20
|
+
item(index: number): MimeType;
|
21
|
+
/**
|
22
|
+
* @param name
|
23
|
+
*/
|
24
|
+
namedItem(name: string): MimeType;
|
25
|
+
/**
|
26
|
+
* Returns the object as a string.
|
27
|
+
*
|
28
|
+
* @returns String.
|
29
|
+
*/
|
30
|
+
toString(): string;
|
31
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/**
|
4
|
+
* MimeTypeArray.
|
5
|
+
*
|
6
|
+
* Reference:
|
7
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/MimeTypeArray.
|
8
|
+
*/
|
9
|
+
var MimeTypeArray = /** @class */ (function () {
|
10
|
+
/**
|
11
|
+
* Constructor.
|
12
|
+
*
|
13
|
+
* @param mimeTypes
|
14
|
+
*/
|
15
|
+
function MimeTypeArray(mimeTypes) {
|
16
|
+
for (var i = 0, max = mimeTypes.length; i < max; i++) {
|
17
|
+
this[i] = mimeTypes[i];
|
18
|
+
this[mimeTypes[i].type] = mimeTypes[i];
|
19
|
+
}
|
20
|
+
this.length = mimeTypes.length;
|
21
|
+
}
|
22
|
+
/**
|
23
|
+
* @param index
|
24
|
+
*/
|
25
|
+
MimeTypeArray.prototype.item = function (index) {
|
26
|
+
return this[index] || null;
|
27
|
+
};
|
28
|
+
/**
|
29
|
+
* @param name
|
30
|
+
*/
|
31
|
+
MimeTypeArray.prototype.namedItem = function (name) {
|
32
|
+
return this[name] || null;
|
33
|
+
};
|
34
|
+
/**
|
35
|
+
* Returns the object as a string.
|
36
|
+
*
|
37
|
+
* @returns String.
|
38
|
+
*/
|
39
|
+
MimeTypeArray.prototype.toString = function () {
|
40
|
+
return '[object MimeTypeArray]';
|
41
|
+
};
|
42
|
+
return MimeTypeArray;
|
43
|
+
}());
|
44
|
+
exports.default = MimeTypeArray;
|
45
|
+
//# sourceMappingURL=MimeTypeArray.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"MimeTypeArray.js","sourceRoot":"","sources":["../../src/navigator/MimeTypeArray.ts"],"names":[],"mappings":";;AAEA;;;;;GAKG;AACH;IAIC;;;;OAIG;IACH,uBAAY,SAAqB;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YACrD,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;SACvC;QACD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;OAEG;IACI,4BAAI,GAAX,UAAY,KAAa;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;IAC5B,CAAC;IAED;;OAEG;IACI,iCAAS,GAAhB,UAAiB,IAAY;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACI,gCAAQ,GAAf;QACC,OAAO,wBAAwB,CAAC;IACjC,CAAC;IACF,oBAAC;AAAD,CAAC,AAvCD,IAuCC"}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import MimeTypeArray from './MimeTypeArray';
|
2
|
+
import PluginArray from './PluginArray';
|
3
|
+
/**
|
4
|
+
* Browser Navigator API.
|
5
|
+
*
|
6
|
+
* Mocked information is taken from FireFox.
|
7
|
+
*
|
8
|
+
* Reference:
|
9
|
+
* https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator.
|
10
|
+
*/
|
11
|
+
export default class Navigator {
|
12
|
+
readonly cookieEnabled: boolean;
|
13
|
+
readonly credentials: string;
|
14
|
+
readonly geolocation: string;
|
15
|
+
readonly language: string;
|
16
|
+
readonly languages: string[];
|
17
|
+
readonly locks: string;
|
18
|
+
readonly maxTouchPoints: number;
|
19
|
+
readonly hardwareConcurrency: number;
|
20
|
+
readonly appCodeName: string;
|
21
|
+
readonly appName: string;
|
22
|
+
readonly appVersion: string;
|
23
|
+
readonly platform: string;
|
24
|
+
readonly product: string;
|
25
|
+
readonly productSub: string;
|
26
|
+
readonly vendor: string;
|
27
|
+
readonly vendorSub: string;
|
28
|
+
readonly userAgent: string;
|
29
|
+
readonly onLine: boolean;
|
30
|
+
readonly permissions: string;
|
31
|
+
readonly webdriver: boolean;
|
32
|
+
readonly doNotTrack: string;
|
33
|
+
readonly mimeTypes: MimeTypeArray;
|
34
|
+
readonly plugins: PluginArray;
|
35
|
+
/**
|
36
|
+
* Returns the object as a string.
|
37
|
+
*
|
38
|
+
* @returns String.
|
39
|
+
*/
|
40
|
+
toString(): string;
|
41
|
+
}
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
var MimeTypeArray_1 = __importDefault(require("./MimeTypeArray"));
|
7
|
+
var PluginArray_1 = __importDefault(require("./PluginArray"));
|
8
|
+
/**
|
9
|
+
* Browser Navigator API.
|
10
|
+
*
|
11
|
+
* Mocked information is taken from FireFox.
|
12
|
+
*
|
13
|
+
* Reference:
|
14
|
+
* https://html.spec.whatwg.org/multipage/system-state.html#dom-navigator.
|
15
|
+
*/
|
16
|
+
var Navigator = /** @class */ (function () {
|
17
|
+
function Navigator() {
|
18
|
+
// False if setting a cookie will be ignored and true otherwise.
|
19
|
+
this.cookieEnabled = true;
|
20
|
+
// TODO: Not implemented.
|
21
|
+
this.credentials = null;
|
22
|
+
// TODO: Not implemented.
|
23
|
+
this.geolocation = null;
|
24
|
+
// String representing the preferred language of the user, usually the language of the browser UI.
|
25
|
+
this.language = 'en-US';
|
26
|
+
// Array of string representing the user's preferred languages.
|
27
|
+
this.languages = ['en-US', 'en'];
|
28
|
+
// TODO: Not implemented.
|
29
|
+
this.locks = null;
|
30
|
+
// Maximum number of simultaneous touch contact points are supported by the current device.
|
31
|
+
this.maxTouchPoints = 0;
|
32
|
+
// Number of logical processors available to run threads on the user's computer.
|
33
|
+
this.hardwareConcurrency = 8;
|
34
|
+
// Browser app code name.
|
35
|
+
this.appCodeName = 'Mozilla';
|
36
|
+
// Browser app name.
|
37
|
+
this.appName = 'Netscape';
|
38
|
+
// Browser app version.
|
39
|
+
this.appVersion = '5.0 (Windows)';
|
40
|
+
// Browser platform.
|
41
|
+
this.platform = 'Win32';
|
42
|
+
// Browser product.
|
43
|
+
this.product = 'Gecko';
|
44
|
+
// Browser product sub.
|
45
|
+
this.productSub = '20100101';
|
46
|
+
// Browser vendor.
|
47
|
+
this.vendor = '';
|
48
|
+
// Browser vendor sub.
|
49
|
+
this.vendorSub = '';
|
50
|
+
// Browser user agent.
|
51
|
+
// "appCodeName/appVersion number (Platform; Security; OS-or-CPU; Localization; rv: revision-version-number) product/productSub Application-Name Application-Name-version".
|
52
|
+
this.userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0';
|
53
|
+
// Boolean value indicating whether the browser is working online.
|
54
|
+
this.onLine = true;
|
55
|
+
// TODO: Not implemented.
|
56
|
+
this.permissions = null;
|
57
|
+
// Boolean Indicates whether the user agent is controlled by automation.
|
58
|
+
this.webdriver = true;
|
59
|
+
// The user's Do Not Track setting, which indicates whether the user is requesting web sites and advertisers to not track them.
|
60
|
+
// The value of the property reflects that of the DNT HTTP header, i.e. Values of "1", "0", or "unspecified".
|
61
|
+
this.doNotTrack = 'unspecified';
|
62
|
+
// Browser mime-types.
|
63
|
+
this.mimeTypes = new MimeTypeArray_1.default([]);
|
64
|
+
// Browser plugins.
|
65
|
+
this.plugins = new PluginArray_1.default([]);
|
66
|
+
}
|
67
|
+
/**
|
68
|
+
* Returns the object as a string.
|
69
|
+
*
|
70
|
+
* @returns String.
|
71
|
+
*/
|
72
|
+
Navigator.prototype.toString = function () {
|
73
|
+
return '[object Navigator]';
|
74
|
+
};
|
75
|
+
return Navigator;
|
76
|
+
}());
|
77
|
+
exports.default = Navigator;
|
78
|
+
//# sourceMappingURL=Navigator.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Navigator.js","sourceRoot":"","sources":["../../src/navigator/Navigator.ts"],"names":[],"mappings":";;;;;AAAA,kEAA4C;AAC5C,8DAAwC;AAExC;;;;;;;GAOG;AACH;IAAA;QACC,gEAAgE;QAChD,kBAAa,GAAY,IAAI,CAAC;QAE9C,yBAAyB;QACT,gBAAW,GAAW,IAAI,CAAC;QAE3C,yBAAyB;QACT,gBAAW,GAAW,IAAI,CAAC;QAE3C,kGAAkG;QAClF,aAAQ,GAAW,OAAO,CAAC;QAE3C,+DAA+D;QAC/C,cAAS,GAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAEtD,yBAAyB;QACT,UAAK,GAAW,IAAI,CAAC;QAErC,2FAA2F;QAC3E,mBAAc,GAAW,CAAC,CAAC;QAE3C,gFAAgF;QAChE,wBAAmB,GAAW,CAAC,CAAC;QAEhD,yBAAyB;QACT,gBAAW,GAAW,SAAS,CAAC;QAEhD,oBAAoB;QACJ,YAAO,GAAW,UAAU,CAAC;QAE7C,uBAAuB;QACP,eAAU,GAAW,eAAe,CAAC;QAErD,oBAAoB;QACJ,aAAQ,GAAW,OAAO,CAAC;QAE3C,mBAAmB;QACH,YAAO,GAAW,OAAO,CAAC;QAE1C,uBAAuB;QACP,eAAU,GAAW,UAAU,CAAC;QAEhD,kBAAkB;QACF,WAAM,GAAW,EAAE,CAAC;QAEpC,sBAAsB;QACN,cAAS,GAAW,EAAE,CAAC;QAEvC,sBAAsB;QACtB,2KAA2K;QAC3J,cAAS,GACxB,gFAAgF,CAAC;QAElF,kEAAkE;QAClD,WAAM,GAAY,IAAI,CAAC;QAEvC,yBAAyB;QACT,gBAAW,GAAW,IAAI,CAAC;QAE3C,wEAAwE;QACxD,cAAS,GAAY,IAAI,CAAC;QAE1C,+HAA+H;QAC/H,6GAA6G;QAC7F,eAAU,GAAW,aAAa,CAAC;QAEnD,sBAAsB;QACN,cAAS,GAAkB,IAAI,uBAAa,CAAC,EAAE,CAAC,CAAC;QAEjE,mBAAmB;QACH,YAAO,GAAgB,IAAI,qBAAW,CAAC,EAAE,CAAC,CAAC;IAU5D,CAAC;IARA;;;;OAIG;IACI,4BAAQ,GAAf;QACC,OAAO,oBAAoB,CAAC;IAC7B,CAAC;IACF,gBAAC;AAAD,CAAC,AAjFD,IAiFC"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import MimeType from './MimeType';
|
2
|
+
/**
|
3
|
+
* Plugin.
|
4
|
+
*/
|
5
|
+
export default class Plugin {
|
6
|
+
[n: number]: MimeType;
|
7
|
+
readonly length: number;
|
8
|
+
readonly description: string;
|
9
|
+
readonly filename: string;
|
10
|
+
readonly name: string;
|
11
|
+
/**
|
12
|
+
* Constructor.
|
13
|
+
*
|
14
|
+
* @param mimeTypes Mime types.
|
15
|
+
* @param description Description.
|
16
|
+
* @param filename Filename.
|
17
|
+
* @param name Name.
|
18
|
+
*/
|
19
|
+
constructor(mimeTypes: MimeType[], description: string, filename: string, name: string);
|
20
|
+
/**
|
21
|
+
* Item.
|
22
|
+
*
|
23
|
+
* @param index Number.
|
24
|
+
* @returns IMimeType.
|
25
|
+
*/
|
26
|
+
item(index: number): MimeType;
|
27
|
+
/**
|
28
|
+
* NamedItem.
|
29
|
+
*
|
30
|
+
* @param name String.
|
31
|
+
* @returns IMimeType.
|
32
|
+
*/
|
33
|
+
namedItem(name: string): MimeType;
|
34
|
+
/**
|
35
|
+
* Returns the object as a string.
|
36
|
+
*
|
37
|
+
* @returns String.
|
38
|
+
*/
|
39
|
+
toString(): string;
|
40
|
+
}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/**
|
4
|
+
* Plugin.
|
5
|
+
*/
|
6
|
+
var Plugin = /** @class */ (function () {
|
7
|
+
/**
|
8
|
+
* Constructor.
|
9
|
+
*
|
10
|
+
* @param mimeTypes Mime types.
|
11
|
+
* @param description Description.
|
12
|
+
* @param filename Filename.
|
13
|
+
* @param name Name.
|
14
|
+
*/
|
15
|
+
function Plugin(mimeTypes, description, filename, name) {
|
16
|
+
this.length = 0;
|
17
|
+
this.description = description;
|
18
|
+
this.filename = filename;
|
19
|
+
this.name = name;
|
20
|
+
for (var i = 0, max = mimeTypes.length; i < max; i++) {
|
21
|
+
this[i] = mimeTypes[i];
|
22
|
+
this[mimeTypes[i].type] = mimeTypes[i];
|
23
|
+
}
|
24
|
+
this.length = mimeTypes.length;
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* Item.
|
28
|
+
*
|
29
|
+
* @param index Number.
|
30
|
+
* @returns IMimeType.
|
31
|
+
*/
|
32
|
+
Plugin.prototype.item = function (index) {
|
33
|
+
return this[index] || null;
|
34
|
+
};
|
35
|
+
/**
|
36
|
+
* NamedItem.
|
37
|
+
*
|
38
|
+
* @param name String.
|
39
|
+
* @returns IMimeType.
|
40
|
+
*/
|
41
|
+
Plugin.prototype.namedItem = function (name) {
|
42
|
+
return this[name] || null;
|
43
|
+
};
|
44
|
+
/**
|
45
|
+
* Returns the object as a string.
|
46
|
+
*
|
47
|
+
* @returns String.
|
48
|
+
*/
|
49
|
+
Plugin.prototype.toString = function () {
|
50
|
+
return '[object Plugin]';
|
51
|
+
};
|
52
|
+
return Plugin;
|
53
|
+
}());
|
54
|
+
exports.default = Plugin;
|
55
|
+
//# sourceMappingURL=Plugin.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/navigator/Plugin.ts"],"names":[],"mappings":";;AAEA;;GAEG;AACH;IAOC;;;;;;;OAOG;IACH,gBAAY,SAAqB,EAAE,WAAmB,EAAE,QAAgB,EAAE,IAAY;QAbtE,WAAM,GAAW,CAAC,CAAC;QAclC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YACrD,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YACvB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;SACvC;QACD,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACI,qBAAI,GAAX,UAAY,KAAa;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACI,0BAAS,GAAhB,UAAiB,IAAY;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACI,yBAAQ,GAAf;QACC,OAAO,iBAAiB,CAAC;IAC1B,CAAC;IACF,aAAC;AAAD,CAAC,AAvDD,IAuDC"}
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import Plugin from './Plugin';
|
2
|
+
/**
|
3
|
+
* PluginArray.
|
4
|
+
*/
|
5
|
+
export default class PluginArray {
|
6
|
+
[n: number]: Plugin;
|
7
|
+
readonly length: number;
|
8
|
+
/**
|
9
|
+
* Constructor.
|
10
|
+
*
|
11
|
+
* @param plugins Plugins.
|
12
|
+
*/
|
13
|
+
constructor(plugins: Plugin[]);
|
14
|
+
/**
|
15
|
+
* Returns an item.
|
16
|
+
*
|
17
|
+
* @param index Index.
|
18
|
+
* @returns Plugin.
|
19
|
+
*/
|
20
|
+
item(index: number): Plugin;
|
21
|
+
/**
|
22
|
+
* Returns an item.
|
23
|
+
*
|
24
|
+
* @param name Name.
|
25
|
+
* @returns Plugin.
|
26
|
+
*/
|
27
|
+
namedItem(name: string): Plugin;
|
28
|
+
/**
|
29
|
+
* Refreshes the list.
|
30
|
+
*/
|
31
|
+
refresh(): void;
|
32
|
+
/**
|
33
|
+
* Returns the object as a string.
|
34
|
+
*
|
35
|
+
* @returns String.
|
36
|
+
*/
|
37
|
+
toString(): string;
|
38
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/**
|
4
|
+
* PluginArray.
|
5
|
+
*/
|
6
|
+
var PluginArray = /** @class */ (function () {
|
7
|
+
/**
|
8
|
+
* Constructor.
|
9
|
+
*
|
10
|
+
* @param plugins Plugins.
|
11
|
+
*/
|
12
|
+
function PluginArray(plugins) {
|
13
|
+
for (var i = 0, max = plugins.length; i < max; i++) {
|
14
|
+
this[i] = plugins[i];
|
15
|
+
this[plugins[i].name] = plugins[i];
|
16
|
+
}
|
17
|
+
this.length = plugins.length;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Returns an item.
|
21
|
+
*
|
22
|
+
* @param index Index.
|
23
|
+
* @returns Plugin.
|
24
|
+
*/
|
25
|
+
PluginArray.prototype.item = function (index) {
|
26
|
+
return this[index] || null;
|
27
|
+
};
|
28
|
+
/**
|
29
|
+
* Returns an item.
|
30
|
+
*
|
31
|
+
* @param name Name.
|
32
|
+
* @returns Plugin.
|
33
|
+
*/
|
34
|
+
PluginArray.prototype.namedItem = function (name) {
|
35
|
+
return this[name] || null;
|
36
|
+
};
|
37
|
+
/**
|
38
|
+
* Refreshes the list.
|
39
|
+
*/
|
40
|
+
PluginArray.prototype.refresh = function () {
|
41
|
+
// Do nothing
|
42
|
+
};
|
43
|
+
/**
|
44
|
+
* Returns the object as a string.
|
45
|
+
*
|
46
|
+
* @returns String.
|
47
|
+
*/
|
48
|
+
PluginArray.prototype.toString = function () {
|
49
|
+
return '[object PluginArray]';
|
50
|
+
};
|
51
|
+
return PluginArray;
|
52
|
+
}());
|
53
|
+
exports.default = PluginArray;
|
54
|
+
//# sourceMappingURL=PluginArray.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"PluginArray.js","sourceRoot":"","sources":["../../src/navigator/PluginArray.ts"],"names":[],"mappings":";;AAEA;;GAEG;AACH;IAIC;;;;OAIG;IACH,qBAAY,OAAiB;QAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YACnD,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;SACnC;QACD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;;;;OAKG;IACI,0BAAI,GAAX,UAAY,KAAa;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;IAC5B,CAAC;IAED;;;;;OAKG;IACI,+BAAS,GAAhB,UAAiB,IAAY;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC;IAC3B,CAAC;IAED;;OAEG;IACI,6BAAO,GAAd;QACC,aAAa;IACd,CAAC;IAED;;;;OAIG;IACI,8BAAQ,GAAf;QACC,OAAO,sBAAsB,CAAC;IAC/B,CAAC;IACF,kBAAC;AAAD,CAAC,AApDD,IAoDC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import Element from '../nodes/element/Element';
|
2
2
|
/**
|
3
|
-
*
|
3
|
+
* Selector item.
|
4
4
|
*/
|
5
5
|
export default class SelectorItem {
|
6
6
|
isAll: boolean;
|
@@ -25,6 +25,14 @@ export default class SelectorItem {
|
|
25
25
|
* @returns TRUE if matching.
|
26
26
|
*/
|
27
27
|
match(element: Element): boolean;
|
28
|
+
/**
|
29
|
+
* Matches a psuedo selector.
|
30
|
+
*
|
31
|
+
* @param element Element.
|
32
|
+
* @param selector Selector.
|
33
|
+
* @returns True if it is a match.
|
34
|
+
*/
|
35
|
+
private matchesPsuedo;
|
28
36
|
/**
|
29
37
|
* Matches a nth-child selector.
|
30
38
|
*
|
@@ -35,13 +43,13 @@ export default class SelectorItem {
|
|
35
43
|
*/
|
36
44
|
private matchesNthChild;
|
37
45
|
/**
|
38
|
-
* Matches a psuedo selector.
|
46
|
+
* Matches a psuedo selector expression.
|
39
47
|
*
|
40
48
|
* @param element Element.
|
41
49
|
* @param psuedo Psuedo name.
|
42
50
|
* @returns True if it is a match.
|
43
51
|
*/
|
44
|
-
private
|
52
|
+
private matchesPsuedoExpression;
|
45
53
|
/**
|
46
54
|
* Matches attribute.
|
47
55
|
*
|
@@ -50,6 +58,14 @@ export default class SelectorItem {
|
|
50
58
|
* @returns True if it is a match.
|
51
59
|
*/
|
52
60
|
private matchesAttribute;
|
61
|
+
/**
|
62
|
+
* Matches class.
|
63
|
+
*
|
64
|
+
* @param element Element.
|
65
|
+
* @param selector Selector.
|
66
|
+
* @returns True if it is a match.
|
67
|
+
*/
|
68
|
+
private matchesClass;
|
53
69
|
/**
|
54
70
|
* Matches attribute name only.
|
55
71
|
*
|
@@ -10,7 +10,7 @@ var PSUEDO_REGEXP = /:([a-zA-Z-]+)\(([0-9n+-]+|odd|even)\)|:not\(([^)]+)\)|:([a-
|
|
10
10
|
var CLASS_REGEXP = /\.([a-zA-Z0-9-_$]+)/g;
|
11
11
|
var TAG_NAME_REGEXP = /^[a-zA-Z0-9-]+/;
|
12
12
|
/**
|
13
|
-
*
|
13
|
+
* Selector item.
|
14
14
|
*/
|
15
15
|
var SelectorItem = /** @class */ (function () {
|
16
16
|
/**
|
@@ -22,8 +22,7 @@ var SelectorItem = /** @class */ (function () {
|
|
22
22
|
this.tagName = null;
|
23
23
|
this.isAll = selector === '*';
|
24
24
|
this.isID = !this.isAll ? selector.startsWith('#') : false;
|
25
|
-
this.isAttribute =
|
26
|
-
!this.isAll && !this.isID && selector.includes('[') && !selector.includes(':not(');
|
25
|
+
this.isAttribute = !this.isAll && !this.isID && selector.includes('[');
|
27
26
|
this.isPseudo = !this.isAll && !this.isID && selector.includes(':');
|
28
27
|
this.isClass = !this.isAll && !this.isID && new RegExp(CLASS_REGEXP, 'g').test(selector);
|
29
28
|
this.tagName = !this.isAll && !this.isID ? selector.match(TAG_NAME_REGEXP) : null;
|
@@ -40,7 +39,6 @@ var SelectorItem = /** @class */ (function () {
|
|
40
39
|
*/
|
41
40
|
SelectorItem.prototype.match = function (element) {
|
42
41
|
var selector = this.selector;
|
43
|
-
var match;
|
44
42
|
// Is all (*)
|
45
43
|
if (this.isAll) {
|
46
44
|
return true;
|
@@ -56,28 +54,12 @@ var SelectorItem = /** @class */ (function () {
|
|
56
54
|
}
|
57
55
|
}
|
58
56
|
// Class match
|
59
|
-
if (this.isClass) {
|
60
|
-
|
61
|
-
while ((match = regexp.exec(selector))) {
|
62
|
-
if (!element.classList.contains(match[1])) {
|
63
|
-
return false;
|
64
|
-
}
|
65
|
-
}
|
57
|
+
if (this.isClass && !this.matchesClass(element, selector)) {
|
58
|
+
return false;
|
66
59
|
}
|
67
60
|
// Pseudo match
|
68
|
-
if (this.isPseudo) {
|
69
|
-
|
70
|
-
while ((match = regexp.exec(selector))) {
|
71
|
-
if (match[1] && !this.matchesNthChild(element, match[1], match[2])) {
|
72
|
-
return false;
|
73
|
-
}
|
74
|
-
else if (match[3] && this.matchesAttribute(element, match[3])) {
|
75
|
-
return false;
|
76
|
-
}
|
77
|
-
else if (match[4] && !this.matchesPsuedo(element, match[4])) {
|
78
|
-
return false;
|
79
|
-
}
|
80
|
-
}
|
61
|
+
if (this.isPseudo && !this.matchesPsuedo(element, selector)) {
|
62
|
+
return false;
|
81
63
|
}
|
82
64
|
// Attribute match
|
83
65
|
if (this.isAttribute && !this.matchesAttribute(element, selector)) {
|
@@ -85,6 +67,32 @@ var SelectorItem = /** @class */ (function () {
|
|
85
67
|
}
|
86
68
|
return true;
|
87
69
|
};
|
70
|
+
/**
|
71
|
+
* Matches a psuedo selector.
|
72
|
+
*
|
73
|
+
* @param element Element.
|
74
|
+
* @param selector Selector.
|
75
|
+
* @returns True if it is a match.
|
76
|
+
*/
|
77
|
+
SelectorItem.prototype.matchesPsuedo = function (element, selector) {
|
78
|
+
var regexp = new RegExp(PSUEDO_REGEXP, 'g');
|
79
|
+
var match;
|
80
|
+
while ((match = regexp.exec(selector))) {
|
81
|
+
var isNotClass = match[3] && match[3].trim()[0] === '.';
|
82
|
+
if (match[1] && !this.matchesNthChild(element, match[1], match[2])) {
|
83
|
+
return false;
|
84
|
+
}
|
85
|
+
else if (match[3] &&
|
86
|
+
((isNotClass && this.matchesClass(element, match[3])) ||
|
87
|
+
(!isNotClass && this.matchesAttribute(element, match[3])))) {
|
88
|
+
return false;
|
89
|
+
}
|
90
|
+
else if (match[4] && !this.matchesPsuedoExpression(element, match[4])) {
|
91
|
+
return false;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
return true;
|
95
|
+
};
|
88
96
|
/**
|
89
97
|
* Matches a nth-child selector.
|
90
98
|
*
|
@@ -136,13 +144,13 @@ var SelectorItem = /** @class */ (function () {
|
|
136
144
|
return children[number - 1] === element;
|
137
145
|
};
|
138
146
|
/**
|
139
|
-
* Matches a psuedo selector.
|
147
|
+
* Matches a psuedo selector expression.
|
140
148
|
*
|
141
149
|
* @param element Element.
|
142
150
|
* @param psuedo Psuedo name.
|
143
151
|
* @returns True if it is a match.
|
144
152
|
*/
|
145
|
-
SelectorItem.prototype.
|
153
|
+
SelectorItem.prototype.matchesPsuedoExpression = function (element, psuedo) {
|
146
154
|
var parent = element.parentNode;
|
147
155
|
if (!parent) {
|
148
156
|
return false;
|
@@ -198,7 +206,7 @@ var SelectorItem = /** @class */ (function () {
|
|
198
206
|
var regexp = new RegExp(ATTRIBUTE_REGEXP, 'g');
|
199
207
|
var match;
|
200
208
|
while ((match = regexp.exec(selector))) {
|
201
|
-
var isPsuedo = match.index > 0 && selector[match.index] === '(';
|
209
|
+
var isPsuedo = match.index > 0 && selector[match.index - 1] === '(';
|
202
210
|
if (!isPsuedo &&
|
203
211
|
((match[1] && !this.matchesAttributeName(element, match[1])) ||
|
204
212
|
(match[2] && !this.matchesAttributeNameAndValue(element, match[2], match[4], match[3])))) {
|
@@ -207,6 +215,26 @@ var SelectorItem = /** @class */ (function () {
|
|
207
215
|
}
|
208
216
|
return true;
|
209
217
|
};
|
218
|
+
/**
|
219
|
+
* Matches class.
|
220
|
+
*
|
221
|
+
* @param element Element.
|
222
|
+
* @param selector Selector.
|
223
|
+
* @returns True if it is a match.
|
224
|
+
*/
|
225
|
+
SelectorItem.prototype.matchesClass = function (element, selector) {
|
226
|
+
var regexp = new RegExp(CLASS_REGEXP, 'g');
|
227
|
+
var classList = element.className.split(' ');
|
228
|
+
var previousIndex = 0;
|
229
|
+
var match;
|
230
|
+
while ((match = regexp.exec(selector)) && match.index === previousIndex) {
|
231
|
+
if (!classList.includes(match[1])) {
|
232
|
+
return false;
|
233
|
+
}
|
234
|
+
previousIndex = match.index + match[0].length - 1;
|
235
|
+
}
|
236
|
+
return true;
|
237
|
+
};
|
210
238
|
/**
|
211
239
|
* Matches attribute name only.
|
212
240
|
*
|