Re: [webcomponents] [Imports]: Consider changing component location to component identifier (bugzilla: 21253) (#235)

@dglazkov I don't believe should be too awesomely complex. 

- Introduce a new term, `import title`, that is used to mean the value of the `title` property of the `link` element, or if that is the empty string the value of the `href` property of the `link` element. This 'special' usage of the `title` attribute is similar to how the `title` property may already be used with the `link` element to identify 'themed' stylesheets, so such usage is not unprecedented.
- The import map should store imports as its items with their import titles as keys (instead of their import locations.)

While existing documents that use imports as defined by the current spec would experience no immediate difference (i.e. breaking changes), they would always be able to easily transition into this more flexible approach, which allows component authors to include links to their preferred CDNs or other servers while allowing component users to manage version conflict resolution on their own terms or even specify their own preferred CDN or forked/patched version of a dependency.

### Example with the current spec

The author of a page would like to import two separate documents, each of which import a slightly different version of jQuery, resulting in two requests for jQuery.

#### `https://example1.com/index.html` (excerpt)
```
<link rel="import" href="https://example2.com/components/modal.html" />
<link rel="import" href="https://example3.com/components/carousel.html" />
```

#### `https://example2.com/components/modal.html` (excerpt)
```
<link rel="import" href="https://some-cdn.com/jquery/2.1.4/jquery.min.html" />
```

#### `https://example3.com/components/carousel.html` (excerpt)
```
<link rel="import" href="https://some-cdn.com/jquery/2.2.0/jquery.min.html" />
```

### Example with proposed change

The author of a page would like to import two separate documents, each of which import a slightly different version of jQuery, but because each of the authors of the two imported documents were courteous enough to provide the import title ("jquery") for their import links, only one request will be made for "jquery". Better yet, the author of the page has in one way or another become aware of the mismatch of dependency versions, and has chosen to import the most desirable version of the dependency by placing their own import link in the master document.

#### `https://example1.com/index.html` (excerpt)
```
<link rel="import" title="jquery" href="https://some-cdn.com/jquery/2.2.0/jquery.min.html" />
<link rel="import" href="https://example2.com/components/modal.html" />
<link rel="import" href="https://example3.com/components/carousel.html" />
```

#### `https://example2.com/components/modal.html` (excerpt)
```
<link rel="import" title="jquery" href="https://some-cdn.com/jquery/2.1.4/jquery.min.html" />
```

#### `https://example3.com/components/carousel.html` (excerpt)
```
<link rel="import" title="jquery" href="https://some-cdn.com/jquery/2.2.0/jquery.min.html" />
```

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/235#issuecomment-186911881

Received on Sunday, 21 February 2016 20:48:19 UTC