') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); feat(cdk): switch injectables to new scope API by jelbourn · Pull Request #10301 · angular/components · GitHub
Skip to content

feat(cdk): switch injectables to new scope API - #10301

Merged
andrewseguin merged 5 commits into
angular:masterfrom
jelbourn:cdk-tree-shakable-services
Mar 19, 2018
Merged

feat(cdk): switch injectables to new scope API#10301
andrewseguin merged 5 commits into
angular:masterfrom
jelbourn:cdk-tree-shakable-services

Conversation

@jelbourn

Copy link
Copy Markdown
Contributor

No description provided.

@jelbournjelbourn added pr: needs review target: major This PR is targeted for the next major release labels Mar 7, 2018
@jelbourn
jelbourn requested review from alxhub and mmalerbaMarch 7, 2018 01:15
@googlebotgooglebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Mar 7, 2018
};

new InjectionToken<() => ScrollStrategy>('cdk-connected-overlay-scroll-strategy', {
scope: APP_ROOT_SCOPE,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: indentation

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Done

@NgModule({
providers: [Platform]
})
@NgModule()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, will we be able to kill this module off in the future? It appears to do nothing now

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I suppose so for now, though we could add other stuff to it. Maybe something like
*cdkIfPlatform="IE11, Safari"

FocusTrapFactory,
AriaDescriber,
LIVE_ANNOUNCER_PROVIDER,
ARIA_DESCRIBER_PROVIDER,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not super familiar with how the app-wide providers work yet, but should the AriaDescriber still be set in the providers in this case? I believe that it's the only reason why, for example, the tooltip imports the A11yModule.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

As I understand it, module imports just for this kind of injectable shouldn't be necessary any more. I'll address those in my next PR that applies this to material.

*
* @docs-private
*/
export const DIR_DOCUMENT = new InjectionToken<Document>('cdk-dir-doc', {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As an aside, do we really need a separate token for the document here? We can easily stub out the DOCUMENT itself in the tests.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

When I was originally doing this I found that re-providing common's DOCUMENT with something else made Angular not work.

@jelbourn
jelbournforce-pushed the cdk-tree-shakable-services branch 2 times, most recently from 52b092f to 60e63eaCompareMarch 8, 2018 00:36
@jelbourn

Copy link
Copy Markdown
ContributorAuthor

I've re-added the old providers because some people were depending on them

@crisbetocrisbeto left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@jelbourn
jelbournforce-pushed the cdk-tree-shakable-services branch 3 times, most recently from bea96c7 to c5b785aCompareMarch 16, 2018 00:21
@jelbourn
jelbournforce-pushed the cdk-tree-shakable-services branch from c5b785a to 5a334d7CompareMarch 16, 2018 17:39
@jelbourn
jelbournforce-pushed the cdk-tree-shakable-services branch from fdafeb4 to aae7243CompareMarch 19, 2018 16:58
@andrewseguinandrewseguin added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Mar 19, 2018
@andrewseguin
andrewseguin merged commit 6405da9 into angular:masterMar 19, 2018
@jelbourn
jelbourn deleted the cdk-tree-shakable-services branch April 2, 2018 22:32
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-botangular-automatic-lock-botBot locked and limited conversation to collaborators Sep 8, 2019
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: mergeThe PR is ready for merge by the caretakercla: yesPR author has agreed to Google's Contributor License Agreementtarget: majorThis PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@jelbourn@crisbeto@mmalerba@andrewseguin@googlebot