-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SVGDOM implementation (uncomplete) #1445
Conversation
Thanks, this is very much appreciated! I'll try to review and see why Travis is failing. |
@@ -0,0 +1,6 @@ | |||
interface SVGElement : Element { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use the interface from https://svgwg.org/svg2-draft/types.html#InterfaceSVGElement instead, commenting out the things that are not implemented yet? Also add a comment at the top of the file like // https://svgwg.org/svg2-draft/types.html#InterfaceSVGElement
, and don't forget a newline at the end of the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, will do. However: May I ask why these interfaces are that different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes are mostly additive. I believe there is a general desire to make SVG elements more like HTML elements where possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What to do with the interfaces which are no longer present in the draft you linked (e.g. SVGStylable)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They can be omitted. Apparently the SVG working group thinks removing them is an acceptable change for SVG2: https://svgwg.org/svg2-draft/changes.html#types
Travis is failing because some lint errors. This will also need some tests before it can be merged. See https://github.com/tmpvar/jsdom/blob/master/Contributing.md#web-platform-feature-tests |
Yes, I saw the errors. I forgot a semicolon somewhere. |
I could need a bit help with these tests. |
You can place them in a new subdirectory of https://github.com/tmpvar/jsdom/tree/master/test/web-platform-tests/to-upstream called "svg". |
How can I test objects which have no constructor? |
Well, are there any APIs that return a SVGStringList on the platform? If so, use them. If not, then there's no reason to add SVGStringList :). |
Well yes. SVGTests returns a stringlist (SVGGraphics implements SVGTests). But I feel uncomfortable using such a long way to get to the strings instead of just testing them straight forward |
Nah, it's fine :) |
This is from the specs about
https://svgwg.org/svg2-draft/struct.html#RequiredExtensionsAttribute I checked. In FF an empty Stringlist is returned. No false and no true. I am not sure which is the correct behavior. PS: Sorry for bothering you with that :D |
No problem! I think the confusion there is that it is talking about the requiredExtensions content attribute, i.e. the thing in the SVG markup itself: This gets kind of complicated, and needs the rules in https://svgwg.org/svg2-draft/types.html#TermReflect :-/. |
The "evaluates to true/false" bit is presumably about how other parts in the spec will say something like "if the requiredExtensions attribute for this evaluates to true", which is a spec-ese way of saying "if all the required extensions are supported." I think. |
I read through this and I think I understand it. However one question remains: how does the Object knows which attribute it is reflecting. Same goes for |
It doesn't need to. obj.list = new List(); // illegal
obj.list.clear(); // totally fine The webidl2js layer ensures that readonly are enforced automatically, so you won't have to explicitly pay attention to that. |
That makes totally sense. Thanks. |
Do you mean how we know which properties are also reflected as attributes? That's sadly not in the webidl language, but rather hidden in the spec language, so actual reading required 😕 Chromium/WebKit has their own proprietary attribute extension which introduces |
no. I know that the specs lay out which attributes have to be reflected. |
Hi folks! I'm very interested in getting this patch into jsdom, so that I can use svg.js to build SVG in Node (see svgdotjs/svg.js#464 as well as this article). Anything I can do to help? More test writing or are there other issues? |
hey edemaine, I actually felt a bit lost in this huge specifications with all this reflection stuff. However - feel free to add your knowledge here. I would be really happy about that! |
I think the main things left to do for landing this initial patch are:
Feel free also to implement a subset, e.g. a basic SVGSVGElement class in a single patch, instead of @Fuzzyma's SVGTests and SVGStringList. That might be an easier patch to land. |
OK, I finally read through this discussion. Fuzzyma's main question seems to be how to make something like Also, I'm a little new to Github -- is the proper way to extend a pull request to clone the new repository, make my own commits, and then submit another pull request? |
Yeah, that sounds good. |
Don't take this to serious. I guess it has some major flaws
Hello! I'm currently working on a project that I'd prefer to use jsdom over phantomjs for. What's the status on this PR/what could I do to help move it along? |
Sorry, I haven't had time to look more / work on this yet. But looks like @Fuzzyma has had some time to write additional tests. Perhaps he could report on what still remains? |
@edemaine no worries. It looks like @nhunzaker is also working on this now. Maybe we could all figure out an MVP for this PR since the W3 spec for SVGs is huge and divide up the work? I'm particularly interesting in seeing |
Digging more into this, I think figuring out a baseline to unblock all of our specific desires is a great starting point. I simply want SVGElement to be defined on the global namespace with basic DOM operations. However I'd be happy to help collaborate on other pieces. |
As far as I can remember my code, the "SVGElement is defined" goal was already achieved^^ |
@nhunzaker Agreed, it'd be nice to release this in pieces, if possible. Personally, I just want enough for |
Might fix #2001 PS: I am not sure if that is the right way :D |
I'm working on creating a cleaned-up version of the SVG-support PRs. Hopefully will finish today! |
Closes jsdom#1445 by superceding it; also supercedes jsdom#1946. Fixes jsdom#1423. Fixes jsdom#1528. Fixes jsdom#1938. Fixes jsdom#2001. Includes only the <svg> element, but this brings along with it the following interfaces: * SVGElement * SVGGraphicsElement * SVGSVGElement * SVGTests * SVGAnimatedString * SVGNumber * SVGStringList
jsdom does not implement SVG elements atm. I would like to change that and thats why I try to kickoff the implementation here.
Its my first day contributing to jsdom so I am sure I did some mistakes. Please correct me whenever you spot something odd.
I will add commits to this PR whenever I finished an element.
The first commit only adds the
SVGElement
as basic implementation.This PR is related to #1423