GithubHelp home page GithubHelp logo

singult's People

Contributors

aperiodic avatar bobby avatar emil0r avatar floybix avatar lynaghk avatar sfnelson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

singult's Issues

Singult doesn't recognize svg <animate> element

Hello,

I may be doing something wrong, but I don't understand what.

I use c2 (and consequently singult) to create an <svg> element, which contains a <path> with <animate> in it. <path> is displayed just fine, however the newly-created <animate> element is not recognised by Chrome as an SVGElement and (consequently?) the animation doesn't happen at all.

I found out that if add the animate into re_svg_tags, like that:

re_svg_tags = /^(animate|svg|g|rect|circle|clipPath|path|line|polygon|polyline|text|textPath)$/;

it works really well.

Do you think it's a singult's issue, or I'm mis-using it somehow?

Thank you!

JS version not working properly

SingultJS.coffee does not appear to have compiled, so the helper functions are not there. Using the singult.coffee namespaced works fine though :).

Really sweet library btw. Having to work with JS it's really nice to have something like this where I can just declare what the HTML is supposed to look like with data structures instead of strings. Big thumbs up!

Throw informative exception when unify is not an only child

An implicit contract on unify is that its output should be the only child of its parent hiccup vector. Currently, if this contract is violated, then Singult trips over an undefined value. Instead, Singult should throw an exception that clearly indicates that unify's contract is being violated in this way.

Devised any clever way to handle raw html?

I've been using singult/c2, and I'm loving it so far, but I recently ran into a snag.
Digging through the comments, I see this is something you're still actively contemplating, re: "else if string_p m #TODO: how to handle raw html?"

Just wondering if you have any insights for stopgaps in the meanwhile.

Use datastructure hashes to optimize DOM walking

Rather than walk everything all the time when merging, since everything is data-driven it may be faster to hash the vectors representing each element, attach that to the live DOM node, and then on future merges only descend and merge when the hash changes.

Splice lazy sequences in Hiccup vectors

Hiccup supports plopping lazy sequences that contain child vectors into a hiccup vector. I think you're aware of the semantics, since you use them in your C2 bullets example. It would be great if Singult supported this as well, so I don't have to do perform unwieldy workarounds with vec and concat. If I try to insert lazy sequences, then singult.coffee.canonicalize_hiccup throws an Uncaught TypeError, with the message that Object div.child,[object Object] has no method 'match'.

CLJ Hiccup compatibility layer

Singult has some extra sugar to expand :style or :properties attributes on elements.
This breaks compatibility with JVM Clojure's Hiccup library.

To make sure that templates/markup can be shared between the clientside and serverside, write a fn to walk Singult vectors and expand the sugar into something Hiccup can eat:

  • :style maps need to be flattened into strings
  • :properties maps need to be expanded into toplevel attributes (checked=true)

Tag attributes are not rendered.

Hi,

I've found that render does not add attrubutes to tags like hiccup does.
So the following

(singult/render [:div
            {:style "background-color:lightblue"}
            [:h2 {:style "color:green"} "I should be green."]
            [:p {:style "color:orange"} "I should be orange."]
        ]))

produces

<div><h2>I should be green.</h2><p>I should be orange.</p></div>

Do I do smth wrong or it is an error in the library?

Thanks in advance :)

  :dependencies [
    [org.clojure/clojure "1.4.0"]
    [com.keminglabs/singult "0.1.5"]]

unify key-fn does not accept (cljs) keywords

Image a data set of (cljs) maps with an :id key. One may want to use

(unify @data some-fn
       :key-fn :id)

But the coffee implementation calls the key-fn directly key_fn(d,i). Clojurescript implements keywords-as-functions by adding the #call method: key_fn.call(null, d, i).

https://github.com/lynaghk/singult/blob/master/src/coffee/Singult.coffee#L223

(One can get around this by specifying an anonymous function instead:

(unify @data some-fn
       :key-fn #(:id %))

)

<img> tags incorrectly render as SVG elements

It appears that the re_svg_tags regexp is incorrectly matching img tags, probably due to its matching unanchored SVG g tags. It may be that adding start/end anchors to the regexp will work, i.e.:

re_svg_tags = /^(svg|g|rect|circle|clipPath|path|line|polygon|polyline|text|textPath)$/

instead of

re_svg_tags = /(svg|g|rect|circle|clipPath|path|line|polygon|polyline|text|textPath)/

but I haven't tested it yet. I'll submit a patch or pull request if I get the chance.

Collections are rendered differently than with Hiccup

Singult renders the following snippet differently than Hiccup:

[:span (list "Hello" [:br] "World")]

Hiccup:

<span>Hello<br>World</span>

Singult:

<span><hello><br>World</hello></span>

Is this the intended behavior? If so, what kind of singult code would generate output like Hiccup's?

BTW, other than this nit, singult appears to be a drop-in replacement for Crate in my app (at least for rendering; Crate has a bunch of utilities for building Hiccup-style vectors, e.g. crate.element, etc). Which is pretty cool.

Support for attribute namespaces

singult determines the namespace of a tag, but not the namespace of a tag attribute. This is a problem with XML attributes that also require a specific namespace to work. For example, browsers refuse rendering an svg:image when the href is not from the xlink namespace i.e. <svg:image xlink:href="..." ... /> This of course requires internally parsing the attributes for namespace like with tags and calling setAttributeNS with the proper namespace. Please consider adding this feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.