In short: I am trying to understand the meaning of this TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element' The error appears while lunching Mediawiki's VisualEditor, as can be seen here:
http://www.wiki.org.il/index.php?title=new-page&veaction=edit
The error doesn't enables creating new pages or editing the wiki anonymously. However, with the use of a different skin the error disappears:
http://www.wiki.org.il/index.php/Main_Page?useskin=vector
The wiki runs on 1.25alpha.
I had this same error showing. When I replaced jQuery selector with normal JavaScript, the error was fixed.
var this_id = $(this).attr('id');
Replace:
getComputedStyle( $('#'+this_id)[0], "")
With:
getComputedStyle( document.getElementById(this_id), "")
The error message says that getComputedStyle
requires the parameter to be Element
type. You receive it because the parameter has an incorrect type.
The most common case is that you try to pass an element that doesn't exist as an argument:
my_element = document.querySelector(#non_existing_id);
Now that element is null
, this will result in mentioned error:
my_style = window.getComputedStyle(my_element);
If it's not possible to always get element correctly, you can, for example, use the following to end function if querySelector
didn't find any match:
if (my_element === null) return;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With