W3C home > Mailing lists > Public > whatwg@whatwg.org > March 2012

[whatwg] A link[scoped] usecase

From: Gray Zhang <otakustay@gmail.com>
Date: Fri, 2 Mar 2012 18:59:19 +0800
Message-ID: <CAKWkPy5vE_k3nc+6H0ce=uVUXhaSFzWC56tuFycKLNpiJPJh+Q@mail.gmail.com>
Hi all:

I've noticed a scoped attribute for link element has been previously
discussed, I'm currently working with some new HTML features and find a
case where the scoped attribute is required on link element.

I'm working on an code editor and building up a scalable theme system, as I
designed, it should satisfy a list of requirements:

1. user (3rd party) can publish their theme to my system
2. user can preview themes and choose one for their editor
3. there is no server side support such as providing a snapshot image for
skin
4. a theme is simply a .css file without anything else

The preview-and-choose panel may look like this:
[image: Inline image 1]

Each preview pane is constructed with pure DOM, if link[scoped] is
supported, I could have some elements and text in a wapper, then apply an
external css on this wrapper so that color/background effect could be
rendered:

<div>
    <!-- This link element only works for it's containing div -->
    <link rel="stylesheet"
href="3rd-party-theme/user-published-20120302133702.css" scoped="scoped" />
    <span class="keyword">function</span><span
class="identifier">test</span>...
</div>

By now, for the reason that there is not link[scoped] and style[scoped] is
not supported for any browser, my solution is add a data-theme attribute on
wrapper element, and the theme .css file should add some extra selector:

.visual-root[data-theme="fireworks"] {
    background-color: #404040;
    color: #addede;
}

The addition of [data-theme="foo"] selector is a really bad smell for me,
in such case I also provided theme author a script to auto generate a theme
structure, but all these could be solved with the support of link[scoped]
element.

-- 
??? GrayZhang
???http://www.otakustay.com
???http://www.weibo.com/otakustay
???otakustay at gmail.com
Received on Friday, 2 March 2012 02:59:19 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:40 UTC