Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

feat(relative uris): Allow relative URIs for templateUrls and cssUrls #1238

Closed
wants to merge 23 commits into from

Conversation

dsalsbury
Copy link

No description provided.

@mhevery mhevery self-assigned this Jul 17, 2014
*/
void resolveDom(Node root, [Uri originalBase]) {
if (originalBase == null) {
// Use baseUrl when dartbug.com/18196 is fixed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like it has been fixed back in April

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed that, thanks!

@vicb
Copy link
Contributor

vicb commented Jul 21, 2014

Does this PR supersede #901 ?

@TedSander
Copy link
Contributor

@vicb Yes it does. It was originally forked from Chris' work. We finally got it to an engineer that had enough time to rebase it and be responsible for the feature.

@dsalsbury
Copy link
Author

I added the test you mentioned, and fixed up those little things. I squashed the commit into the original one in the interest of keeping this nice and clean, so if it's hard to see the changes from the original commit let me know and I'll separate them again. Thanks!

@cbracken
Copy link
Contributor

Thanks again @dsalsbury for taking this over and getting it into shape!

One thing that should be noted in the release notes is that this is a breaking change for anyone using templateUrl: "package:..." syntax. I'd originally written a patch to support it, but I think not supporting it is the correct thing to do for consistency with other client-side URIs.

@TedSander
Copy link
Contributor

@cbracken "package:.." is not a concept that is in Angular at all so we shouldn't have to mark it as a breaking change. It is something we use internally only. It will be a transition that we have to deal with.

@chirayuk
Copy link
Contributor

fyi, for those observing, we're still actively working on this one.

String resolve(String uri, Type type) {
var typeMirror = reflectType(type);
LibraryMirror lib = typeMirror.owner;
if (typeMirror == Uri.base) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var libUri = lib.uri;
if (libUri begins with Uri.base) {
  libUri = libUri.path;
}

rkirov and others added 17 commits August 5, 2014 17:31
Some clients do not generate static factories for test code, and instead
directly depend on TestBed constructor. This commit adds a new
constructor is basically the injector factory method, requiring only
injector vs a full set of parameters.

Once clients have been moved to use fromInjector method (or even better
a transformer run for test code), we can change the constructor
dependencies in a non-breaking way.

Closes dart-archive#1271
Angular's pubspec for intl spans versions with breaking changes.  For
Angular, a change in date formatting would be a breaking change but
changes do to CLDR updates are not breaking changes.  This commit
updates a test to swap out a locale with a CLDR update to one that
wasn't updated to enable it to pass across the CLDR breaking change.

Closes dart-archive#1203
in _recordAdd(), previous could never be null as the list is never empty
(it has at least a marker).
in _recordRemove(), when the list is composed of a single record, it
must be the record we're trying to remove (and we assert that).

Closes dart-archive#1256
Fixes dart-archive#1128
Closes dart-archive#1132

The insertBefore argument is never used in the current code
(see the v0.13.0 tag for the exact history of this version)
Example:
When defining a component called 'foo' in file
'/myproject/has/many/folders/foo.dart', prior to the change you would
do so thusly:
@component(
   selector: 'foo',
   templateUrl: '/myproject/has/many/folders/foo.html',
   cssUrl: '/myproject/has/many/folders/foo.css'
)

The above is still valid, but now can also be defined rather more
succinctly as:
@component(
   selector: 'foo',
   templateUrl: 'foo.html',
   cssUrl: 'foo.css'
)

A full table of what URLs will be changed/unchanged is below:
You Say:				Transformer replies:
'packages/foo/bar.html'			'packages/foo/bar.html'
'foo.html'				'packages/foo/bar.html'
'./foo.html'				'packages/foo/bar.html'
'/foo.html'				'/foo.html'
'http://google.com/foo.html'		'http://google.com/foo.html'

*Note  that as  shown any absolute paths you define will not be
bothered by the transformer, so if you have a templateUrl living at
<root>/foo.html, you can still reach it with '/foo.html'!

This feature is defaulted to an "off" state through the addition
of the ResourceResolverConfig class.  To turn the feature on, bind
a new ResourceResolverConfig in your module:

module.bind(ResourceResolverConfig, toValue:
	new ResourceResolverConfig(useRelativeUrls: true));
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.