Use ResizeObserver and MutationObserver to detect detach/attach/resize (#7104)

* Use Resize/MutationObserver to detect detach/attach/resize
* Cleanup
* Review update
* Restore infinite resize detection (#6011)
This commit is contained in:
Jukka Kurkela
2020-02-17 18:00:03 +02:00
committed by GitHub
parent 7397a41fac
commit bfe34214ac
17 changed files with 189 additions and 494 deletions

View File

@@ -303,20 +303,6 @@ describe('Chart', function() {
});
});
describe('config.options.responsive: false', function() {
it('should not inject the resizer element', function() {
var chart = acquireChart({
options: {
responsive: false
}
});
var wrapper = chart.canvas.parentNode;
expect(wrapper.childNodes.length).toBe(1);
expect(wrapper.firstChild.tagName).toBe('CANVAS');
});
});
describe('config.options.responsive: true (maintainAspectRatio: false)', function() {
it('should fill parent width and height', function() {
var chart = acquireChart({
@@ -633,9 +619,6 @@ describe('Chart', function() {
});
waitForResize(chart, function() {
var resizer = wrapper.firstChild;
expect(resizer.className).toBe('chartjs-size-monitor');
expect(resizer.tagName).toBe('DIV');
expect(chart).toBeChartOfSize({
dw: 455, dh: 355,
rw: 455, rh: 355,
@@ -644,8 +627,6 @@ describe('Chart', function() {
var target = document.createElement('div');
waitForResize(chart, function() {
expect(target.firstChild).toBe(resizer);
expect(wrapper.firstChild).toBe(null);
expect(chart).toBeChartOfSize({
dw: 640, dh: 480,
rw: 640, rh: 480,
@@ -939,31 +920,6 @@ describe('Chart', function() {
});
});
describe('controller.destroy', function() {
it('should remove the resizer element when responsive: true', function(done) {
var chart = acquireChart({
options: {
responsive: true
}
});
waitForResize(chart, function() {
var wrapper = chart.canvas.parentNode;
var resizer = wrapper.firstChild;
expect(wrapper.childNodes.length).toBe(2);
expect(resizer.className).toBe('chartjs-size-monitor');
expect(resizer.tagName).toBe('DIV');
chart.destroy();
expect(wrapper.childNodes.length).toBe(1);
expect(wrapper.firstChild.tagName).toBe('CANVAS');
done();
});
});
});
describe('controller.reset', function() {
it('should reset the chart elements', function() {
var chart = acquireChart({