Skip to content

Standardize namespace prefix syntax ("svg|…" vs. "svg:…"). #21

Closed
Houssk/d3
#1

Description

@mbostock

CSS and XML use different conventions for namespace prefixes. For example, in XML "svg:g" refers to a g element with the svg namespace prefix; in CSS3 the equivalent is "svg|g". D3 uses both conventions, which leads to confusion. For example:

d3.selectAll("path")
    .data(…)
  .enter("svg:path")
    …

In fact, most current browsers implement the Selectors API Level 1, which does not support namespaces. Level 2 appears the same, strangely.

Still, it might be a good idea to use the same syntax everywhere, although "svg|g" and "xlink|href" is definitely less familiar to folks... And we'd have to have some way of stripping the namespaces from the selectors, as this functionality is not implemented in the standard. Hmm, or not.

Activity

  1. mbostock commented on Feb 8, 2011

    @mbostock
    MemberAuthor

    I think it's only possible to standardize on "|" rather than ":", without interfering with CSS selectors. So you could say:

    d3.selectAll("svg|path")
        .data(…)
      .enter("svg|path")
        …
    

    We'd have to strip the namespace from the selector, though, which is icky. And I still think "svg|path" is less obvious than "svg:path". So best to keep it as-is for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions