mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-06 08:24:05 +01:00
Fix DomPlatform.isAttached (#9448)
This commit is contained in:
@@ -382,6 +382,6 @@ export default class DomPlatform extends BasePlatform {
|
||||
*/
|
||||
isAttached(canvas) {
|
||||
const container = _getParentNode(canvas);
|
||||
return !!(container && _getParentNode(container));
|
||||
return !!(container && container.isConnected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,17 +408,22 @@ describe('Platform.dom', function() {
|
||||
var platform = new DomPlatform();
|
||||
var canvas = document.createElement('canvas');
|
||||
var div = document.createElement('div');
|
||||
var anotherDiv = document.createElement('div');
|
||||
|
||||
expect(platform.isAttached(canvas)).toEqual(false);
|
||||
div.appendChild(canvas);
|
||||
expect(platform.isAttached(canvas)).toEqual(false);
|
||||
document.body.appendChild(div);
|
||||
anotherDiv.appendChild(div);
|
||||
expect(platform.isAttached(canvas)).toEqual(false);
|
||||
document.body.appendChild(anotherDiv);
|
||||
|
||||
expect(platform.isAttached(canvas)).toEqual(true);
|
||||
|
||||
anotherDiv.removeChild(div);
|
||||
expect(platform.isAttached(canvas)).toEqual(false);
|
||||
div.removeChild(canvas);
|
||||
expect(platform.isAttached(canvas)).toEqual(false);
|
||||
document.body.removeChild(div);
|
||||
document.body.removeChild(anotherDiv);
|
||||
expect(platform.isAttached(canvas)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user