rustwasm / wasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript
https://rustwasm.github.io/docs/wasm-bindgen/
Apache License 2.0
7.75k stars 1.07k forks source link

Struct web_sys::WebGlContextAttributes doesnt have getter of its field?How can i get the value of field in it? #2747

Open HolyZheng opened 2 years ago

HolyZheng commented 2 years ago

Summary

Struct web_sys::WebGlContextAttributes doesnt have getter of its field?How can i get the value of field in it?

Additional Details

In Javascript:

var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');
let  attr =  gl.getContextAttributes();

// I can get the field value.
attr.antialias

but in rust

 let antialias_info: WebGlContextAttributes = gl.get_context_attributes().unwrap();
// this will throw error
 let antialias = antialias_info.antialias;
attempted to take value of method `antialias` on type `web_sys::WebGlContextAttributes`
method, not a field

And this is the doc of Struct web_sys::WebGlContextAttributes

alexcrichton commented 2 years ago

This may be that the *.webidl files we use need to be updated, in which case a PR should suffice to update them which will generate the appropriate getters.