0
我正在使用jsdom創建window.document
對象並將其傳遞到正在測試的函數中。然而,創建一個新元素後,我不能設置dataset
屬性:jsdom - 如何設置元素數據集?
var my = function(document){
var item = document.createElement('a');
gridItem.tabIndex = 1;
gridItem.dataset.num = 1;
};
運行我的測試時,我得到的錯誤是:
TypeError: Cannot set property 'num' of undefined