@@ -16,7 +16,7 @@ const {
1616} = require ( 'internal/errors' ) . codes ;
1717
1818// The HTML spec has an implied default type of `'javascript'`.
19- const kImplicitAssertType = 'javascript' ;
19+ const kImplicitTypeAttribute = 'javascript' ;
2020
2121/**
2222 * Define a map of module formats to import attributes types (the value of
@@ -25,11 +25,11 @@ const kImplicitAssertType = 'javascript';
2525 */
2626const formatTypeMap = {
2727 '__proto__' : null ,
28- 'builtin' : kImplicitAssertType ,
29- 'commonjs' : kImplicitAssertType ,
28+ 'builtin' : kImplicitTypeAttribute ,
29+ 'commonjs' : kImplicitTypeAttribute ,
3030 '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
3333} ;
3434
3535/**
@@ -38,9 +38,9 @@ const formatTypeMap = {
3838 * `import './file.js' with { type: 'javascript' }` throws.
3939 * @type {Array<string, string> }
4040 */
41- const supportedAssertionTypes = ArrayPrototypeFilter (
41+ const supportedTypeAttributes = ArrayPrototypeFilter (
4242 ObjectValues ( formatTypeMap ) ,
43- ( type ) => type !== kImplicitAssertType ) ;
43+ ( type ) => type !== kImplicitTypeAttribute ) ;
4444
4545
4646/**
@@ -50,7 +50,7 @@ const supportedAssertionTypes = ArrayPrototypeFilter(
5050 * @param {Record<string, string> } importAttributes Validations for the
5151 * module import.
5252 * @returns {true }
53- * @throws {TypeError } If the format and assertion type are incompatible.
53+ * @throws {TypeError } If the format and type attribute are incompatible.
5454 */
5555function validateAttributes ( url , format ,
5656 importAttributes = { __proto__ : null } ) {
@@ -68,16 +68,16 @@ function validateAttributes(url, format,
6868 // formats in the future.
6969 return true ;
7070
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
7373 // must not be set on the import attributes object.
7474 if ( ! ObjectPrototypeHasOwnProperty ( importAttributes , 'type' ) ) {
7575 return true ;
7676 }
7777 return handleInvalidType ( url , importAttributes . type ) ;
7878
7979 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.
8181 return true ;
8282
8383 default :
@@ -92,16 +92,16 @@ function validateAttributes(url, format,
9292}
9393
9494/**
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 .
9696 * @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
9898 */
9999function handleInvalidType ( url , type ) {
100100 // `type` might have not been a string.
101101 validateString ( type , 'type' ) ;
102102
103103 // `type` might not have been one of the types we understand.
104- if ( ! ArrayPrototypeIncludes ( supportedAssertionTypes , type ) ) {
104+ if ( ! ArrayPrototypeIncludes ( supportedTypeAttributes , type ) ) {
105105 throw new ERR_IMPORT_ATTRIBUTE_UNSUPPORTED ( 'type' , type ) ;
106106 }
107107
@@ -111,6 +111,6 @@ function handleInvalidType(url, type) {
111111
112112
113113module . exports = {
114- kImplicitAssertType ,
114+ kImplicitTypeAttribute ,
115115 validateAttributes,
116116} ;
0 commit comments