我正在尝试通过在SauceLabs中运行它们来修复Internet Explorer中sklad库的失败测试。不幸的是我发现对象存储的autoIncrement属性总是未定义的,但我找不到任何证据表明IE中的这个属性已被破坏。或者我错过了什么?
var sDBName = "ADatabase" + Date.now();
var nDBVersion = 1.0;
var req = indexedDB.open( sDBName, nDBVersion );
req.onsuccess = function(evt) {
var tr = evt.target.result.transaction(['MyObjectStore'], 'readwrite'); // reaonly
tr.oncomplete = function () {
console.log('transaction completed')
}
var objStore = tr.objectStore('MyObjectStore');
console.log('objStore', objStore);
// expect to get true, but it's undefined
console.log('objStore.autoIncrement', objStore.autoIncrement);
console.log('objStore.keyPath', objStore.keyPath);
}
req.onupgradeneeded = function(evt) {
console.log('upgradeneeded')
var hDBHandle = evt.target.result;
var sStoreName = "MyObjectStore";
var oDBOptions = { keyPath : "RecordID", autoIncrement : true };
var oStore = hDBHandle.createObjectStore( sStoreName, oDBOptions );
var oIxOptions = { unique: false, multientry: false };
oStore.createIndex( "SortByTitle", "DeckTitle", oIxOptions );
oStore.createIndex( "SortByDesc", "Description", oIxOptions );
console.log('upgraded')
}
答案 0 :(得分:0)
坏消息:这是一个错误,它已在Microsoft错误跟踪器中关闭:https://connect.microsoft.com/IE/Feedback/Details/772726
好消息:你可以像我一样(link)为这个属性写一个polyfill。我们的想法是检查autoIncrement是否未定义。如果未定义,则应启动读/写事务,将数据添加到对象库。根据响应/异常,您可以了解此对象存储是否具有true或false autoIncrement字段。当然你应该在之后回滚这个交易。
如果您不想使用所有这些东西我为您编写了一个库:link