Surprisingly, this Apple page has Element.prototype equal to undefined, so I cannot use this awesome snippet of code.
Are there any reason for doing this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Apple is using the Coherent JS framework which has this block of code:
window.Elementis originally a function, but it’s being replaced and extended with a regular object. Only functions have.prototypeproperties.Workaround:
The prototype chain for any HTML element seems to be:
You should be able to attach your referenced code to the prototype to any of the bold objects in the chain and get the style for an html element. I would not recommend this in production code as modifying objects like that is generally considered harmful, but if you are just trying to export a style from another website, it should work well enough.