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

feat(components): add support for CSS encapsulation to transcluding components #1315

Merged
merged 1 commit into from
Sep 11, 2014

Conversation

vsavkin
Copy link
Contributor

@vsavkin vsavkin commented Aug 5, 2014

This PR depends on #1293.

  • Extract ComponentCssLoader so it can be shared by ShadowDomComponentFactory and TranscludingComponentFactory
  • Implement a CSS transformer similar to the one provided by Platform.JS.
  • Rename EventHandler into ShadowBoundary
  • Rename WebPlatform into WebPlatformShim and provide two implementations: one based on platform.js and the other one built into Angular.

TODO:

  • Refactor ShadowDomComponentFactory#call and TranscludingComponentFactory#call.
  • Test ShimmingViewCache in isolation. At the moment it is tested indirectly.
  • Test the default shim

Includes #1304

@mhevery mhevery added cla: yes and removed cla: no labels Aug 5, 2014
bool get isBody => true;
}

class _Lexer {
Copy link
Contributor

Choose a reason for hiding this comment

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

could csslib help here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll investigate if it can be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could be used, but since the library is generic and does more than we need, importing it adds 160Kb to the generated (and minified) JS file. So we should probably try to build something more tailored to our use case.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would have think that the tree shaking would have been more effective...
I think we can forget it then

@vicb vicb changed the title Add support for CSS encapsulation to transcluding components [WIP] Add support for CSS encapsulation to transcluding components Aug 5, 2014
@vicb
Copy link
Contributor

vicb commented Aug 5, 2014

@vsavkin IIUC this PR fixes #1300 & includes #1304, could you confirm ?

Could you also please what is left to do (as this is a WIP) to ease the review ?

Very good job at first look !

@vicb
Copy link
Contributor

vicb commented Aug 5, 2014

What about #1305, do you think it could be added ?

@vsavkin
Copy link
Contributor Author

vsavkin commented Aug 5, 2014

@vicb #1300 is next on my list. It will be a part of this PR. #1304 has not been merged into master yet, so it is not included. I have not thought about #1305 much, so I need to look into it more.

@vicb
Copy link
Contributor

vicb commented Aug 5, 2014

In think you already have solved #1304, that was the issue with the cache keys (not depending on the selector)

@vsavkin vsavkin mentioned this pull request Aug 6, 2014
abstract class WebPlatformShim {
/**
* Because this code uses `strictStyling` for the polymer css shim, it is required to add the
* custom element’s name as an attribute on all DOM nodes in the shadowRoot (e.g. <span x-foo>).
Copy link
Contributor

Choose a reason for hiding this comment

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

@vsavkin this comment should probably be updated ?

@vsavkin
Copy link
Contributor Author

vsavkin commented Aug 6, 2014

@vicb you are totally right about #1304. It is included into this PR.

Talking of #1305. I've added unit tests for ShimmingViewCache and DefaultPlatformShim, but not for PlatformJsBasedShim. The main responsibility of PlatformJsBasedShim is to delegate to Platform.js, so I'm not sure how much value we would get by isolating it from platform.js. To do it we would have to wrap platform.js in another object, register it with DI, and then pass it to PlatformJsBasedShim. Not sure if all this is necessary, considering we would have to have some integration tests (or e2e tests) anyways. What do you think?

@@ -53,7 +53,8 @@ void main() {
beforeEachModule((Module m) {
return m
..bind(ComponentFactory, toImplementation: TranscludingComponentFactory)
..bind(SimpleComponent);
..bind(SimpleComponent)
..bind(DefaultPlatformShim, toImplementation: DefaultPlatformShim);
Copy link
Contributor

Choose a reason for hiding this comment

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

bind(DefaultPlatformShim); ?

@vsavkin vsavkin changed the title [WIP] Add support for CSS encapsulation to transcluding components feat(components): add support for CSS encapsulation to transcluding components Aug 6, 2014
@vicb
Copy link
Contributor

vicb commented Aug 7, 2014

I would prefer to see some unit tests, e2e tests only test for whatever
platform they're executed on.

It should not be that complex by using the way I've suggested in the PR:

  • create mocks for ShadowCss and Platform, assign the later to
    js.context['Platform'] beforeEach tests
  • check that the expected methods are called on the mock according to
    the config (shim / native)
  • restore the initial js.context['Platform'] afterEach test

If you can come something simple like this, it's probably worth it. If
it gets too complex e2e might be enough.

On 08/06/2014 04:27 PM, Victor Savkin wrote:

@vicb https://github.com/vicb you are totally right about #1304
#1304. It is included
into this PR.

Talking of #1305
#1305. I've added unit
tests for ShimmingViewCache and DefaultPlatformShim, but not for
PlatformJsBasedShim. The main responsibility of PlatformJsBasedShim is
to delegate to Platform.js, so I'm not sure how much value we would
get by isolating it from platform.js. To do it we would have to wrap
platform.js in another object, register it with DI, and then pass it
to PlatformJsBasedShim. Not sure if all this is necessary, considering
we would have to have some integration tests (or e2e tests) anyways.
What do you think?


Reply to this email directly or view it on GitHub
#1315 (comment).

@vsavkin
Copy link
Contributor Author

vsavkin commented Aug 7, 2014

@vicb I'm not sure if we should mock the Platform object. Doing so breaks "Don't Mock What You Don't Own". I'd prefer to wrap the Platform object into something we control and mock that.


async.Future<String> _fetch(String cssUrl) {
return http.get(cssUrl, cache: templateCache)
.then((resp) => resp.responseText, onError: (e) => '/*\n$e\n*/\n');
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please remove the \n from here, they make testing with IE fails, see https://github.com/angular/angular.dart/pull/1288/files#diff-184d55c4be9ba89ff317b308735c6ae9R91. You would also need to update the corresponding test.

I think is it much easier to include this here are this will not be updated while merging the PRs to master as the file has changed.

@vsavkin
Copy link
Contributor Author

vsavkin commented Aug 30, 2014

@mhevery is it "review" or "rebase"?

@vsavkin vsavkin force-pushed the add_css_encapsulation branch from 22d4294 to 78175c4 Compare September 2, 2014 17:02
@vsavkin vsavkin force-pushed the add_css_encapsulation branch 2 times, most recently from 3b174c0 to d616410 Compare September 3, 2014 13:42
@chirayuk chirayuk force-pushed the master branch 2 times, most recently from 8fd235c to 50e2645 Compare September 5, 2014 23:10
@vsavkin vsavkin force-pushed the add_css_encapsulation branch 2 times, most recently from 1ba3218 to ad194a0 Compare September 10, 2014 16:28
…ents

* Extract ComponentCssLoader so it can be shared by ShadowDomComponentFactory and TranscludingComponentFactory
* Provide a built-in implementation of WebPlatformShim using css_shim
* Implement a CSS transformer similar to the one provided by Platform.JS
* Rename EventHandler into ShadowBoundary
@vsavkin vsavkin force-pushed the add_css_encapsulation branch from ad194a0 to 18843e1 Compare September 11, 2014 16:25
@vsavkin vsavkin merged commit 18843e1 into dart-archive:master Sep 11, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

5 participants