@@ -16,7 +16,7 @@ const {
16
16
} = require ( 'internal/errors' ) . codes ;
17
17
18
18
// The HTML spec has an implied default type of `'javascript'`.
19
- const kImplicitAssertType = 'javascript' ;
19
+ const kImplicitTypeAttribute = 'javascript' ;
20
20
21
21
/**
22
22
* Define a map of module formats to import attributes types (the value of
@@ -25,11 +25,11 @@ const kImplicitAssertType = 'javascript';
25
25
*/
26
26
const formatTypeMap = {
27
27
'__proto__' : null ,
28
- 'builtin' : kImplicitAssertType ,
29
- 'commonjs' : kImplicitAssertType ,
28
+ 'builtin' : kImplicitTypeAttribute ,
29
+ 'commonjs' : kImplicitTypeAttribute ,
30
30
'json' : 'json' ,
31
- 'module' : kImplicitAssertType ,
32
- 'wasm' : kImplicitAssertType , // It's unclear whether the HTML spec will require an attribute type or not for Wasm; see https://github.com/WebAssembly/esm-integration/issues/42
31
+ 'module' : kImplicitTypeAttribute ,
32
+ 'wasm' : kImplicitTypeAttribute , // It's unclear whether the HTML spec will require an type attribute or not for Wasm; see https://github.com/WebAssembly/esm-integration/issues/42
33
33
} ;
34
34
35
35
/**
@@ -38,9 +38,9 @@ const formatTypeMap = {
38
38
* `import './file.js' with { type: 'javascript' }` throws.
39
39
* @type {Array<string, string> }
40
40
*/
41
- const supportedAssertionTypes = ArrayPrototypeFilter (
41
+ const supportedTypeAttributes = ArrayPrototypeFilter (
42
42
ObjectValues ( formatTypeMap ) ,
43
- ( type ) => type !== kImplicitAssertType ) ;
43
+ ( type ) => type !== kImplicitTypeAttribute ) ;
44
44
45
45
46
46
/**
@@ -50,7 +50,7 @@ const supportedAssertionTypes = ArrayPrototypeFilter(
50
50
* @param {Record<string, string> } importAttributes Validations for the
51
51
* module import.
52
52
* @returns {true }
53
- * @throws {TypeError } If the format and assertion type are incompatible.
53
+ * @throws {TypeError } If the format and type attribute are incompatible.
54
54
*/
55
55
function validateAttributes ( url , format ,
56
56
importAttributes = { __proto__ : null } ) {
@@ -68,16 +68,16 @@ function validateAttributes(url, format,
68
68
// formats in the future.
69
69
return true ;
70
70
71
- case kImplicitAssertType :
72
- // This format doesn't allow an import assertion type, so the property
71
+ case kImplicitTypeAttribute :
72
+ // This format doesn't allow an import type attribute , so the property
73
73
// must not be set on the import attributes object.
74
74
if ( ! ObjectPrototypeHasOwnProperty ( importAttributes , 'type' ) ) {
75
75
return true ;
76
76
}
77
77
return handleInvalidType ( url , importAttributes . type ) ;
78
78
79
79
case importAttributes . type :
80
- // The asserted type is the valid type for this format.
80
+ // The type attribute is the valid type for this format.
81
81
return true ;
82
82
83
83
default :
@@ -92,16 +92,16 @@ function validateAttributes(url, format,
92
92
}
93
93
94
94
/**
95
- * Throw the correct error depending on what's wrong with the type assertion .
95
+ * Throw the correct error depending on what's wrong with the type attribute .
96
96
* @param {string } url The resolved URL for the module to be imported
97
- * @param {string } type The value of the import assertion `type` property
97
+ * @param {string } type The value of the import attributes' `type` property
98
98
*/
99
99
function handleInvalidType ( url , type ) {
100
100
// `type` might have not been a string.
101
101
validateString ( type , 'type' ) ;
102
102
103
103
// `type` might not have been one of the types we understand.
104
- if ( ! ArrayPrototypeIncludes ( supportedAssertionTypes , type ) ) {
104
+ if ( ! ArrayPrototypeIncludes ( supportedTypeAttributes , type ) ) {
105
105
throw new ERR_IMPORT_ATTRIBUTE_UNSUPPORTED ( 'type' , type ) ;
106
106
}
107
107
@@ -111,6 +111,6 @@ function handleInvalidType(url, type) {
111
111
112
112
113
113
module . exports = {
114
- kImplicitAssertType ,
114
+ kImplicitTypeAttribute ,
115
115
validateAttributes,
116
116
} ;
0 commit comments