saltarelle / saltarelleweb Goto Github PK
View Code? Open in Web Editor NEWWeb bindings for the Saltarelle C# to JavaScript compiler
License: Other
Web bindings for the Saltarelle C# to JavaScript compiler
License: Other
Because this will make diffing easier
After I have regenerated the C# source from WebIDL, the commit contains lot of changes caused by member reordering. It seems to be caused by locale dependent ordering.
... or any other type that is ignored due to metadata in the webidl
I'm trying to create SVG elements and I'm struggling to figure out how it is meant to work.
There are three main problems.
Firstly Document.CreateElementNS("http://www.w3.org/2000/svg", "svg")
works, but returns an Element, which I can't easily convert to an SVGSVGElement (which extends SVGGraphicsElement, SVGElement, and XmlElement). The Element.As<T>()
method has a type constraint of Element.
Similarly, some of the other methods such as GetElementById() mean that even if the SVG element exists, you can't get it back as the right type.
I have a hack for this first issue, which essentially does what the As() does.
The second issue is a follow on of the above. How do I create sub nodes of the SVG? In JS you would just use document.createElementNS() again. The reason I mention it separately, is that in JS some SVG related objects have createXXX() methods on the SVGSVGElement.
The third aspect is that even when you have created, say, an SVGRectElement, the properties are read only, so you can't set the width/height,x,y,rx,ry. Limiting the usefulness of these classes.
The DOM interface : https://developer.mozilla.org/en-US/docs/Web/API/SVGRectElement also says the properties are readonly.
So how am I meant to set attributes of the SVGElement?
Ultimately, I guess that I'm just misunderstanding how to drive the interface.
So if there any examples of creating an element and some simple shapes inside that you could point me at, that would be a great help.
InputElement.Value collides with XmlNode.Value. So inputElement.Value
is compiled into inputElement.nodeValue
instead of inputElement.value
.
What about to add interface IEnumerable<Element>
to ElementCollection
(and maybe other similar collections)?
The event creation helpers, such as "initMouseEvent" and "initEvent" are missing in 3.x. While these APIs might be deprecated, they're needed for backwards compatibility with older browsers.
You can find their specification here.
http://www.w3.org/TR/DOM-Level-2-Events/events.html
The standard pattern is
var myEvent = document.createEvent('MyEventType');
myEvent.initEvent(...);
document.dispatchEvent(myEvent);
So ideally the parameter and return types of those methods should match up in a reasonable way.
Some WebGL code needs casting int/uint casting, for instance:
gl.TexParameteri(WebGLRenderingContext.TEXTURE_2D, WebGLRenderingContext.TEXTURE_WRAP_S, WebGLRenderingContext.CLAMP_TO_EDGE);
Since WebGLRenderingContext
contains method with the last parameter of type int
:
// IDL: void texParameteri(GLenum target, GLenum pname, GLint param);
public void TexParameteri(uint target, uint pname, int param);
and uint
constant:
// IDL: const GLenum CLAMP_TO_EDGE = 0x812F;
public const uint CLAMP_TO_EDGE = 33071;
The problem is caused because GLenum
is defined in IDL as:
typedef unsigned long GLenum;
There are more cases of casting problem in the spec, e.g. Uniform1i
vs. TEXTURE_2D
.
One possible workaround is to define alternative methods, such as:
public void TexParameteri(uint target, uint pname, uint param) { }
public void Uniform1i(WebGLUniformLocation location, uint x) { }
However similar problem is with:
GLint getAttribLocation(WebGLProgram? program, DOMString name)
vs.
void enableVertexAttribArray(GLuint index)
from WebGL specification.
I think that the spec considers unsigned long
as non-negative integer implicitly convertible to common integer long
.
So, the solution from my point of view is to translate IDL's unsigned long
to C#'s int
.
As the title says, System.Html.Event.Data and Source are missing. These are used with AddEventListener and PostMessage. There may be more, not sure.
For instance, I would like to specify [ScriptName("keypress")]
and change the name of ElementEvents.Keypress
to ElementEvents.KeyPress
.
Not exactly a bug, but I'm finding the new usage of XmlElement as a return type for various API functions as rather inconvenient, resulting in a lot of manual casting. I understand that these are probably perfectly valid type constraints in terms of the spec, but they're very inconvenient to work with since there are more relevant casts will pass in most common usage.
Some examples:
Element.ParentNode
returns XmlElement
instead of Element
Document.CreateElement
returns XmlElement
Document.DocumentElement
returns XmlElement
This means a line like
Document.DocumentElement.AddEventListener("event", ...);
has to turn into
((Element)Document.DocumentElement).AddEventListener("event, ...);
or be separated into two lines, or make use of an extension method to do the cast (which can be more inconvenient given namespace issues).
I don't particularly have a proposed solution, I just feel like the more simplified typing was a lot easier to work with.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.