mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 18:20:51 +00:00
Always bind static operations to their class
For example, `Promise.resolve` must always be called with the `Promise` constructor as its `this`, or else it will throw an error.
This commit is contained in:
parent
96ad97a9f9
commit
f9ac4e9c90
@ -1868,24 +1868,28 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
),
|
||||
}
|
||||
} else {
|
||||
let location = if *is_static { "" } else { ".prototype" };
|
||||
let (location, binding) = if *is_static {
|
||||
("", format!(".bind({})", class))
|
||||
} else {
|
||||
(".prototype", "".into())
|
||||
};
|
||||
|
||||
match kind {
|
||||
shared::OperationKind::Regular => {
|
||||
format!("{}{}.{}", class, location, import.function.name)
|
||||
format!("{}{}.{}{}", class, location, import.function.name, binding)
|
||||
}
|
||||
shared::OperationKind::Getter(g) => {
|
||||
self.cx.expose_get_inherited_descriptor();
|
||||
format!(
|
||||
"GetOwnOrInheritedPropertyDescriptor({}{}, '{}').get",
|
||||
class, location, g,
|
||||
"GetOwnOrInheritedPropertyDescriptor({}{}, '{}').get{}",
|
||||
class, location, g, binding,
|
||||
)
|
||||
}
|
||||
shared::OperationKind::Setter(s) => {
|
||||
self.cx.expose_get_inherited_descriptor();
|
||||
format!(
|
||||
"GetOwnOrInheritedPropertyDescriptor({}{}, '{}').set",
|
||||
class, location, s,
|
||||
"GetOwnOrInheritedPropertyDescriptor({}{}, '{}').set{}",
|
||||
class, location, s, binding,
|
||||
)
|
||||
}
|
||||
shared::OperationKind::IndexingGetter => panic!("indexing getter should be structural"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user