55import 'dart:js_interop' ;
66
77import 'package:code_builder/code_builder.dart' as code;
8+ import 'package:collection/collection.dart' ;
89import 'package:path/path.dart' as p;
910
1011import 'banned_names.dart' ;
@@ -1244,6 +1245,7 @@ class Translator {
12441245 code.ExtensionType _extensionType ({
12451246 required String jsName,
12461247 required String dartClassName,
1248+ required List <idl.ExtendedAttribute > extendedAttributes,
12471249 required MdnInterface ? mdnInterface,
12481250 required BCDInterfaceStatus ? interfaceStatus,
12491251 required List <String > implements ,
@@ -1257,6 +1259,12 @@ class Translator {
12571259
12581260 final jsObject = _typeReference (_RawType ('JSObject' , false ));
12591261 const representationFieldName = '_' ;
1262+ final legacyNameSpace = extendedAttributes
1263+ .firstWhereOrNull (
1264+ (extendedAttribute) => extendedAttribute.name == 'LegacyNamespace' ,
1265+ )
1266+ ? .rhs
1267+ .value;
12601268 final instancePropertyMethods = < code.Method > [];
12611269 final staticPropertyMethods = < code.Method > [];
12621270 final propertySpecs = _properties (properties, mdnInterface);
@@ -1267,7 +1275,12 @@ class Translator {
12671275 return code.ExtensionType ((b) => b
12681276 ..docs.addAll (docs)
12691277 ..annotations.addAll (
1270- _jsOverride (isObjectLiteral || jsName == dartClassName ? '' : jsName))
1278+ _jsOverride (
1279+ legacyNameSpace != null
1280+ ? '$legacyNameSpace .$jsName '
1281+ : (isObjectLiteral || jsName == dartClassName ? '' : jsName),
1282+ ),
1283+ )
12711284 ..name = dartClassName
12721285 ..primaryConstructorName = '_'
12731286 ..representationDeclaration = code.RepresentationDeclaration ((b) => b
@@ -1300,6 +1313,7 @@ class Translator {
13001313 final type = interfacelike.type;
13011314 final isNamespace = type == 'namespace' ;
13021315 final isDictionary = type == 'dictionary' ;
1316+ final extendedAttributes = idlInterfacelike.extAttrs.toDart;
13031317
13041318 final mdnInterface = docProvider.interfaceFor (jsName);
13051319
@@ -1327,6 +1341,7 @@ class Translator {
13271341 _extensionType (
13281342 jsName: jsName,
13291343 dartClassName: dartClassName,
1344+ extendedAttributes: extendedAttributes,
13301345 mdnInterface: mdnInterface,
13311346 interfaceStatus: interfaceStatus,
13321347 implements : implements ,
0 commit comments