I need to add a member to an HTMLElement
, in other words, I need to store data into an element. This is what I would like to achieve as if I am coding in ScriptSharp.
/** My method */
public DoIt(element: Element, obj: Object) {
Literal({0}.extended = {1}, element, obj); // This is not standard Typescript!
}
In my example ScriptSharp (a project to convert C# code into Javascript) provides a Script.Literal
object that allows developers to write plain Javascript when a C# abstraction is not possible.
So that the Javascript output is:
// Probably Typescript will render it a bit differently, but basically
// this is what we get in the end...
var _doit = function(element, obj) {
element.extended = obj;
};
How can I achieve this in Typescript? Or maybe I should handle this problem in a different way?