Closed cdoublev closed 1 year ago
We typically rely on the impl class to implement attribute getters properly. We can’t do what you suggest in the general case, since any?
(or even undefined?
) contains both null and undefined.
I suspected there is a reason, thanks. Too bad because given this interface:
interface Foo {
string? attribute bar;
}
the implementation requires:
class FooImplementation {
constructor(globalObject, { bar }) {
this._bar = bar
}
get bar() {
return this._bar ?? null
}
}
instead of:
class FooImplementation {
constructor(globalObject, { bar }) {
this.bar = bar
}
}
There are a number of cases in CSS. I read in the Web IDL spec that the inner type of a nullable cannot be any
.
Please let me know if useNullAsFallback = this.idl.idlTpe.nullable && this.idl.idlType.idlType !== 'undefined'
can be an option.
In an instance of a wrapper class, the getter of an attribute whose definition is a type qualified with
?
(nullable type), returnsundefined
instead ofnull
, as defined in the Web IDL spec:https://webidl.spec.whatwg.org/#idl-nullable-type
I guess it can be fixed by appending
?? null
togetterBody
in https://github.com/jsdom/webidl2js/blob/90ba8b1139baece4929944b81f08a588c8a6dc81/lib/constructs/attribute.js#L45, but there seems to be many occurrences and you surely know how to fix it quickly and properly, if there are no reason for returningundefined
that I am not aware of.