From a805d841af1f23be1b94461d7db3410010159a46 Mon Sep 17 00:00:00 2001 From: Camila Belo Date: Fri, 20 May 2022 15:45:52 +0200 Subject: [PATCH] refactor(techdocs): delete inject css Signed-off-by: Camila Belo --- .../techdocs/src/reader/transformers/index.ts | 1 - .../src/reader/transformers/injectCss.test.ts | 40 ------------------- .../src/reader/transformers/injectCss.ts | 31 -------------- 3 files changed, 72 deletions(-) delete mode 100644 plugins/techdocs/src/reader/transformers/injectCss.test.ts delete mode 100644 plugins/techdocs/src/reader/transformers/injectCss.ts diff --git a/plugins/techdocs/src/reader/transformers/index.ts b/plugins/techdocs/src/reader/transformers/index.ts index 56846a51cd..dc3c43a584 100644 --- a/plugins/techdocs/src/reader/transformers/index.ts +++ b/plugins/techdocs/src/reader/transformers/index.ts @@ -25,6 +25,5 @@ export * from './copyToClipboard'; export * from './removeMkdocsHeader'; export * from './simplifyMkdocsFooter'; export * from './onCssReady'; -export * from './injectCss'; export * from './scrollIntoAnchor'; export * from './transformer'; diff --git a/plugins/techdocs/src/reader/transformers/injectCss.test.ts b/plugins/techdocs/src/reader/transformers/injectCss.test.ts deleted file mode 100644 index 6d0eb8daa9..0000000000 --- a/plugins/techdocs/src/reader/transformers/injectCss.test.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { createTestShadowDom } from '../../test-utils'; -import { injectCss } from './injectCss'; - -describe('injectCss', () => { - it('should inject style with passed css in head', async () => { - const html = ` - - - - - `; - const injectedCss = '* {background-color: #fff}'; - - const shadowDom = await createTestShadowDom(html, { - preTransformers: [injectCss({ css: injectedCss })], - postTransformers: [], - }); - - const styleElement = shadowDom.querySelector('head > style'); - - expect(styleElement).toBeTruthy(); - expect(styleElement!.innerHTML).toEqual(injectedCss); - }); -}); diff --git a/plugins/techdocs/src/reader/transformers/injectCss.ts b/plugins/techdocs/src/reader/transformers/injectCss.ts deleted file mode 100644 index c847d3e1d8..0000000000 --- a/plugins/techdocs/src/reader/transformers/injectCss.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2020 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import type { Transformer } from './transformer'; - -type InjectCssOptions = { - css: string; -}; - -export const injectCss = ({ css }: InjectCssOptions): Transformer => { - return dom => { - dom - .getElementsByTagName('head')[0] - .insertAdjacentHTML('beforeend', ``); - - return dom; - }; -};