@@ -194,6 +194,26 @@ export class Type extends Base {
194194 * validate ( defs ) {
195195 yield * this . extAttrs . validate ( defs ) ;
196196
197+ if ( this . idlType === "BufferSource" ) {
198+ // XXX: For now this is a hack. Consider moving parents' extAttrs into types as the spec says:
199+ // https://webidl.spec.whatwg.org/#idl-annotated-types
200+ for ( const extAttrs of [ this . extAttrs , this . parent ?. extAttrs ] ) {
201+ for ( const extAttr of extAttrs ) {
202+ if ( extAttr . name !== "AllowShared" ) {
203+ continue ;
204+ }
205+ const message = `\`[AllowShared] BufferSource\` is now replaced with AllowSharedBufferSource.` ;
206+ yield validationError (
207+ this . tokens . base ,
208+ this ,
209+ "migrate-allowshared" ,
210+ message ,
211+ { autofix : replaceAllowShared ( this , extAttr , extAttrs ) }
212+ ) ;
213+ }
214+ }
215+ }
216+
197217 if ( this . idlType === "void" ) {
198218 const message = `\`void\` is now replaced by \`undefined\`. Refer to the \
199219[relevant GitHub issue](https://github.com/whatwg/webidl/issues/60) \
@@ -273,6 +293,23 @@ for more information.`;
273293 }
274294}
275295
296+ /**
297+ * @param {Type } type
298+ * @param {import("./extended-attributes.js").SimpleExtendedAttribute } extAttr
299+ * @param {ExtendedAttributes } extAttrs
300+ */
301+ function replaceAllowShared ( type , extAttr , extAttrs ) {
302+ return ( ) => {
303+ const index = extAttrs . indexOf ( extAttr ) ;
304+ extAttrs . splice ( index , 1 ) ;
305+ if ( ! extAttrs . length && type . tokens . base . trivia . match ( / ^ \s $ / ) ) {
306+ type . tokens . base . trivia = "" ; // (let's not remove comments)
307+ }
308+
309+ type . tokens . base . value = "AllowSharedBufferSource" ;
310+ } ;
311+ }
312+
276313/**
277314 * @param {Type } type
278315 */
0 commit comments