🐛CSS should not process duplicated in experimentalStyleIsolation (#2075)
This commit is contained in:
parent
389ba257b0
commit
7fa3eb28f3
|
|
@ -301,6 +301,35 @@ test('should not transform @font-face', () => {
|
||||||
expect(removeWs(styleNode.textContent)).toBe(removeWs(expectValue));
|
expect(removeWs(styleNode.textContent)).toBe(removeWs(expectValue));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not transform style that has already been transform [1]', async () => {
|
||||||
|
const actualValue = '.react15-main {display: flex;}';
|
||||||
|
const expectValue = 'div[data-qiankun="react15"] .react15-main {display: flex;}';
|
||||||
|
|
||||||
|
const styleNode = fakeStyleNode('');
|
||||||
|
CSSProcessor.process(styleNode, 'div[data-qiankun="react15"]');
|
||||||
|
|
||||||
|
const textNode = document.createTextNode(actualValue);
|
||||||
|
styleNode.appendChild(textNode);
|
||||||
|
|
||||||
|
await sleep(10);
|
||||||
|
|
||||||
|
CSSProcessor.process(styleNode, 'div[data-qiankun="react15"]');
|
||||||
|
|
||||||
|
expect(removeWs(styleNode.textContent)).toBe(removeWs(expectValue));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not transform style that has already been transform [2]', async () => {
|
||||||
|
const actualValue = '.react15-main {display: flex;}';
|
||||||
|
const expectValue = 'div[data-qiankun="react15"] .react15-main {display: flex;}';
|
||||||
|
|
||||||
|
const styleNode = fakeStyleNode(actualValue);
|
||||||
|
CSSProcessor.process(styleNode, 'div[data-qiankun="react15"]');
|
||||||
|
|
||||||
|
CSSProcessor.process(styleNode, 'div[data-qiankun="react15"]');
|
||||||
|
|
||||||
|
expect(removeWs(styleNode.textContent)).toBe(removeWs(expectValue));
|
||||||
|
});
|
||||||
|
|
||||||
// jest cannot handle @page directive correctly
|
// jest cannot handle @page directive correctly
|
||||||
test.skip('should not transform @page', () => {
|
test.skip('should not transform @page', () => {
|
||||||
const actualValue = '@page {margin: 1cm;}';
|
const actualValue = '@page {margin: 1cm;}';
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@ export class ScopedCSS {
|
||||||
}
|
}
|
||||||
|
|
||||||
process(styleNode: HTMLStyleElement, prefix: string = '') {
|
process(styleNode: HTMLStyleElement, prefix: string = '') {
|
||||||
|
if (ScopedCSS.ModifiedTag in styleNode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (styleNode.textContent !== '') {
|
if (styleNode.textContent !== '') {
|
||||||
const textNode = document.createTextNode(styleNode.textContent || '');
|
const textNode = document.createTextNode(styleNode.textContent || '');
|
||||||
this.swapNode.appendChild(textNode);
|
this.swapNode.appendChild(textNode);
|
||||||
|
|
@ -52,6 +56,7 @@ export class ScopedCSS {
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
this.swapNode.removeChild(textNode);
|
this.swapNode.removeChild(textNode);
|
||||||
|
(styleNode as any)[ScopedCSS.ModifiedTag] = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user