Skip to content

Commit

Permalink
Release (#1489)
Browse files Browse the repository at this point in the history
* fix: move width & height from style to attribute in <foreignObject> (#1486)

* fix: move width & height from style to attribute in <foreignObject> #1485

* chore: commit changeset

* chore(release): bump version (#1488)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 15, 2023
1 parent 28753a8 commit 992e9d5
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 6 deletions.
109 changes: 109 additions & 0 deletions __tests__/integration/__node__tests__/svg/html.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
const util = require('util');
// ref: https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
// ref: https://github.com/jsdom/jsdom/issues/2524
Object.defineProperty(window, 'TextEncoder', {
writable: true,
value: util.TextEncoder,
});
Object.defineProperty(window, 'TextDecoder', {
writable: true,
value: util.TextDecoder,
});

const fs = require('fs');
const { JSDOM } = require('jsdom');
const xmlserializer = require('xmlserializer');
const { HTML, Canvas } = require('@antv/g');
const { Renderer } = require('@antv/g-svg');
const { sleep } = require('../../util');

// create a renderer, unregister plugin relative to DOM
const renderer = new Renderer();
const domInteractionPlugin = renderer.getPlugin('dom-interaction');
renderer.unregisterPlugin(domInteractionPlugin);

const dom = new JSDOM(`
<div id="container">
</div>
`);

const SIZE = 200;
const canvas = new Canvas({
container: 'container',
width: SIZE,
height: SIZE,
renderer,
document: dom.window.document,
requestAnimationFrame: dom.window.requestAnimationFrame,
cancelAnimationFrame: dom.window.cancelAnimationFrame,
});

const RESULT_IMAGE = '/html.svg';
const BASELINE_IMAGE_DIR = '/snapshots';

describe('Render <HTML> with g-svg', () => {
afterEach(() => {
canvas.removeChildren();
});

afterAll(() => {
canvas.destroy();
});

it('should render HTML on server-side correctly.', async () => {
await canvas.ready;
const html = new HTML({
id: 'p1',
name: 'p2-name',
className: 'p2-classname',
style: {
x: 50,
y: 50,
width: 60,
height: 30,
innerHTML: 'p2',
},
});
canvas.appendChild(html);

const html2 = new HTML({
id: 'p1',
name: 'p2-name',
className: 'p2-classname',
style: {
x: 50,
y: 150,
width: 60,
height: 30,
innerHTML: '<div>p2</div>',
fontSize: '20px',
textAlign: 'center',
color: 'red',
},
});
canvas.appendChild(html2);

await sleep(120);

// fs.writeFileSync(
// __dirname + RESULT_IMAGE,
// xmlserializer.serializeToString(
// dom.window.document.getElementById('container').children[0],
// ),
// );

const snapshot = fs.readFileSync(
__dirname + BASELINE_IMAGE_DIR + RESULT_IMAGE,
{
encoding: 'utf8',
flag: 'r',
},
);

expect(
xmlserializer.serializeToString(
dom.window.document.getElementById('container').children[0],
),
).toBe(snapshot);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions packages/g-mobile-svg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-mobile-svg

## 0.10.14

### Patch Changes

- Updated dependencies [c0b9fc49]
- @antv/g-plugin-svg-renderer@1.10.14
- @antv/g-plugin-svg-picker@1.9.14

## 0.10.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-mobile-svg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-mobile-svg",
"version": "0.10.13",
"version": "0.10.14",
"description": "A renderer implemented by SVG in mobile environment",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-plugin-rough-svg-renderer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-plugin-rough-svg-renderer

## 1.9.15

### Patch Changes

- @antv/g-svg@1.10.14

## 1.9.14

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-rough-svg-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-rough-svg-renderer",
"version": "1.9.14",
"version": "1.9.15",
"description": "A G plugin of renderer implementation with rough.js",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-plugin-svg-picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-plugin-svg-picker

## 1.9.14

### Patch Changes

- Updated dependencies [c0b9fc49]
- @antv/g-plugin-svg-renderer@1.10.14

## 1.9.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-svg-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-svg-picker",
"version": "1.9.13",
"version": "1.9.14",
"description": "A G plugin for picking in SVG",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-plugin-svg-renderer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-plugin-svg-renderer

## 1.10.14

### Patch Changes

- c0b9fc49: Move width & height from style to attribute in <foreignObject>.

## 1.10.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-svg-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-svg-renderer",
"version": "1.10.13",
"version": "1.10.14",
"description": "A G plugin of renderer implementation with SVG",
"keywords": [
"antv",
Expand Down
3 changes: 3 additions & 0 deletions packages/g-plugin-svg-renderer/src/SVGRendererPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ export class SVGRendererPlugin implements RenderingPlugin {
$el.style['border-style'] = 'dashed';
} else if (name === 'innerHTML') {
this.createOrUpdateInnerHTML(document, $el, usedValue);
} else if (name === 'width' || name === 'height' || name === 'class') {
// width & height are both required for <foreignObject> and cannot be used as style.
$el.setAttribute(name, usedValue.toString());
} else if (
name !== 'x' &&
name !== 'y' &&
Expand Down
8 changes: 8 additions & 0 deletions packages/g-plugin-zdog-svg-renderer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-plugin-zdog-svg-renderer

## 1.2.15

### Patch Changes

- Updated dependencies [c0b9fc49]
- @antv/g-plugin-svg-renderer@1.10.14
- @antv/g-svg@1.10.14

## 1.2.14

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-zdog-svg-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-zdog-svg-renderer",
"version": "1.2.14",
"version": "1.2.15",
"description": "A G plugin of renderer implementation with Zdog",
"keywords": [
"antv",
Expand Down
8 changes: 8 additions & 0 deletions packages/g-svg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-svg

## 1.10.14

### Patch Changes

- Updated dependencies [c0b9fc49]
- @antv/g-plugin-svg-renderer@1.10.14
- @antv/g-plugin-svg-picker@1.9.14

## 1.10.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-svg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-svg",
"version": "1.10.13",
"version": "1.10.14",
"description": "A renderer implemented by SVG",
"keywords": [
"antv",
Expand Down

0 comments on commit 992e9d5

Please sign in to comment.