@wordpress/element 4.0.1-next.5df0cd52b7.0 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +2 -2
- package/build/index.js +8 -8
- package/build/platform.android.js +3 -1
- package/build/platform.android.js.map +1 -1
- package/build/platform.ios.js +3 -1
- package/build/platform.ios.js.map +1 -1
- package/build/platform.js +2 -1
- package/build/platform.js.map +1 -1
- package/build/raw-html.js +19 -9
- package/build/raw-html.js.map +1 -1
- package/build/react.js +49 -45
- package/build/react.js.map +1 -1
- package/build/serialize.js +12 -7
- package/build/serialize.js.map +1 -1
- package/build-module/platform.android.js +3 -1
- package/build-module/platform.android.js.map +1 -1
- package/build-module/platform.ios.js +3 -1
- package/build-module/platform.ios.js.map +1 -1
- package/build-module/platform.js +2 -1
- package/build-module/platform.js.map +1 -1
- package/build-module/raw-html.js +19 -10
- package/build-module/raw-html.js.map +1 -1
- package/build-module/react.js +5 -1
- package/build-module/react.js.map +1 -1
- package/build-module/serialize.js +9 -4
- package/build-module/serialize.js.map +1 -1
- package/build-types/create-interpolate-element.d.ts +1 -1
- package/build-types/create-interpolate-element.d.ts.map +1 -1
- package/build-types/platform.d.ts +1 -0
- package/build-types/raw-html.d.ts +4 -3
- package/build-types/raw-html.d.ts.map +1 -1
- package/build-types/react.d.ts +3 -3
- package/build-types/react.d.ts.map +1 -1
- package/build-types/serialize.d.ts +2 -2
- package/build-types/serialize.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/platform.android.js +2 -0
- package/src/platform.ios.js +2 -0
- package/src/platform.js +1 -0
- package/src/raw-html.js +16 -6
- package/src/test/raw-html.js +46 -11
- package/tsconfig.tsbuildinfo +1 -895
package/src/test/raw-html.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Internal dependencies
|
|
@@ -11,20 +11,55 @@ import RawHTML from '../raw-html';
|
|
|
11
11
|
describe( 'RawHTML', () => {
|
|
12
12
|
it( 'is dangerous', () => {
|
|
13
13
|
const html = '<p>So scary!</p>';
|
|
14
|
-
const
|
|
14
|
+
const { container } = render( <RawHTML>{ html }</RawHTML> );
|
|
15
|
+
const expected = '<div><p>So scary!</p></div>';
|
|
15
16
|
|
|
16
|
-
expect(
|
|
17
|
-
expect( element.prop( 'dangerouslySetInnerHTML' ).__html ).toBe( html );
|
|
18
|
-
expect( element.prop( 'children' ) ).toBe( undefined );
|
|
17
|
+
expect( container.innerHTML ).toBe( expected );
|
|
19
18
|
} );
|
|
20
19
|
|
|
21
|
-
it( '
|
|
20
|
+
it( 'adds other props to container element', () => {
|
|
22
21
|
const html = '<p>So scary!</p>';
|
|
23
|
-
const
|
|
22
|
+
const { container } = render(
|
|
23
|
+
<RawHTML className="foo">{ html }</RawHTML>
|
|
24
|
+
);
|
|
24
25
|
|
|
25
|
-
expect(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
expect( container.innerHTML ).toBe(
|
|
27
|
+
'<div class="foo"><p>So scary!</p></div>'
|
|
28
|
+
);
|
|
29
|
+
} );
|
|
30
|
+
|
|
31
|
+
it( 'concatenates children if multiple children present', () => {
|
|
32
|
+
const html = '<p>So scary!</p>';
|
|
33
|
+
const html2 = '<p>Extra paragraph</p>';
|
|
34
|
+
|
|
35
|
+
const { container } = render(
|
|
36
|
+
<RawHTML>
|
|
37
|
+
{ html }
|
|
38
|
+
{ html2 }
|
|
39
|
+
</RawHTML>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const expected = '<div><p>So scary!</p><p>Extra paragraph</p></div>';
|
|
43
|
+
expect( container.innerHTML ).toBe( expected );
|
|
44
|
+
} );
|
|
45
|
+
|
|
46
|
+
it( 'renders an empty container if there are no children', () => {
|
|
47
|
+
const { container } = render( <RawHTML></RawHTML> );
|
|
48
|
+
|
|
49
|
+
const expected = '<div></div>';
|
|
50
|
+
expect( container.innerHTML ).toBe( expected );
|
|
51
|
+
} );
|
|
52
|
+
|
|
53
|
+
it( 'ignores non-string based children', () => {
|
|
54
|
+
const html = '<p>So scary!</p>';
|
|
55
|
+
const { container } = render(
|
|
56
|
+
<RawHTML>
|
|
57
|
+
{ html }
|
|
58
|
+
<p>Ignore this!</p>
|
|
59
|
+
</RawHTML>
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const expected = '<div><p>So scary!</p></div>';
|
|
63
|
+
expect( container.innerHTML ).toBe( expected );
|
|
29
64
|
} );
|
|
30
65
|
} );
|