GithubHelp home page GithubHelp logo

[idea] pseudo inline styles about nanohtml HOT 6 CLOSED

choojs avatar choojs commented on June 2, 2024
[idea] pseudo inline styles

from nanohtml.

Comments (6)

shama avatar shama commented on June 2, 2024 1

Maybe it's because I rarely use inline styles and when I do, it's almost always directly on the element. Non-inline CSS is far superior IMO so this convenience isn't useful to me.

But, if the overwhelming consensus is to add this back then we can.

from nanohtml.

yoshuawuyts avatar yoshuawuyts commented on June 2, 2024 1

from nanohtml.

tunnckoCore avatar tunnckoCore commented on June 2, 2024

@shama @yoshuawuyts could we revive that by adding really few bytes?

Very basic and almost enough support for this can be implemented in 2-4 lines

      // support style as object
      // both `fontSize` and `font-size` work that way
      if (key === 'style' && typeof val === 'object') {
        for (var k in val) {
          el.style[k] = val[k]
        }
        continue
      }

The cool thing is that DOM is smart enough, so it accepts el.style.fontSize and el.style['font-size'] by default.

from nanohtml.

shama avatar shama commented on June 2, 2024
var bel = require('bel')
var css = require('dom-css')
var element = bel`<div>Hello!</div>`
css(element, {
  position: 'absolute',
  top: 100,
  left: 200
})

Is pretty much the same code but then you can control which version of dom-css you use or even use an entirely different CSS library. It's not about implementation difficultly but rather keeping this library generic.

from nanohtml.

timwis avatar timwis commented on June 2, 2024

That starts to be a lot less convenient when element is a tree and you want to style its children though. You'd have to use querySelector and such. :-/

from nanohtml.

tunnckoCore avatar tunnckoCore commented on June 2, 2024

Probably. But it cost nothing and DOM itself supports it. If anyone want more then he can use something like dom-css or such.

from nanohtml.

Related Issues (20)

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.