Browse Source

refactor: change DomInsertionsService's method name

pull/3475/head
mehmet-erim 7 years ago
parent
commit
e0c9928346
  1. 2
      npm/ng-packs/packages/core/src/lib/services/dom-insertion.service.ts
  2. 10
      npm/ng-packs/packages/core/src/lib/tests/content.strategy.spec.ts
  3. 2
      npm/ng-packs/packages/core/src/lib/tests/dom-insertion.service.spec.ts
  4. 2
      npm/ng-packs/packages/theme-basic/src/lib/services/initial.service.ts
  5. 2
      npm/ng-packs/packages/theme-shared/src/lib/tokens/append-content.token.ts

2
npm/ng-packs/packages/core/src/lib/services/dom-insertion.service.ts

@ -6,7 +6,7 @@ import { generateHash } from '../utils';
export class DomInsertionService {
readonly inserted = new Set();
insertElement(contentStrategy: ContentStrategy) {
insertContent(contentStrategy: ContentStrategy) {
const hash = generateHash(contentStrategy.content);
if (this.inserted.has(hash)) return;

10
npm/ng-packs/packages/core/src/lib/tests/content.strategy.spec.ts

@ -66,16 +66,6 @@ describe('ScriptContentStrategy', () => {
});
});
// describe('CONTENT_SECURITY_STRATEGY', () => {
// test.each`
// name | Strategy | nonce
// ${'Loose'} | ${LooseContentSecurityStrategy} | ${uuid()}
// ${'None'} | ${NoContentSecurityStrategy} | ${undefined}
// `('should successfully map $name to $Strategy.name', ({ name, Strategy, nonce }) => {
// expect(CONTENT_SECURITY_STRATEGY[name](nonce)).toEqual(new Strategy(nonce));
// });
// });
describe('CONTENT_STRATEGY', () => {
test.each`
name | Strategy | domStrategy

2
npm/ng-packs/packages/core/src/lib/tests/dom-insertion.service.spec.ts

@ -9,7 +9,7 @@ describe('DomInsertionService', () => {
beforeEach(() => (spectator = createService()));
it('should be insert an element', () => {
spectator.service.insertElement(CONTENT_STRATEGY.AppendStyleToHead('.test {}'));
spectator.service.insertContent(CONTENT_STRATEGY.AppendStyleToHead('.test {}'));
expect(spectator.service.inserted.has(1437348290)).toBe(true);
});
});

2
npm/ng-packs/packages/theme-basic/src/lib/services/initial.service.ts

@ -28,6 +28,6 @@ export class InitialService {
}
appendStyle() {
this.domInsertion.insertElement(CONTENT_STRATEGY.AppendStyleToHead(styles));
this.domInsertion.insertContent(CONTENT_STRATEGY.AppendStyleToHead(styles));
}
}

2
npm/ng-packs/packages/theme-shared/src/lib/tokens/append-content.token.ts

@ -8,7 +8,7 @@ export const THEME_SHARED_APPEND_CONTENT = new InjectionToken<void>('THEME_SHARE
factory: () => {
const domInsertion: DomInsertionService = inject(DomInsertionService);
domInsertion.insertElement(CONTENT_STRATEGY.AppendStyleToHead(styles));
domInsertion.insertContent(CONTENT_STRATEGY.AppendStyleToHead(styles));
import('chart.js').then(() => chartJsLoaded$.next(true));
},

Loading…
Cancel
Save