Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade causes event.currentTarget undefined with IndexedDBShim #87

Open
erik-southmedia opened this issue Aug 28, 2014 · 2 comments
Open
Labels

Comments

@erik-southmedia
Copy link

I'm using db.js with IndexedDBShim for iOS Safari. My HTML5 app opens a database and synchronises data with the server when it starts. However, when db.js gets the "upgrade needed" event and tries to create the schema I get an error in the Safari console about an undefined object for "e.currentTarget.transaction" on line 543 of db.js. This line is:

store = e.currentTarget.transaction.objectStore(tableName);

I don't know if this is correct for IndexedDB but the shim library seems to return events only with "target" defined. So I did a workaround with the following code.

if(e.currentTarget !== undefined)
{
store = e.currentTarget.transaction.objectStore(tableName);
}
else store = e.target.transaction.objectStore(tableName);

I hope this helps someone.

@aaronpowell
Copy link
Owner

Hmm it's unclear from the spec which I should be looking at, currentTarget or target, but I think I should actually be looking at something else, the result.request property, which would require a bit more refactoring.

@brettz9
Copy link
Contributor

brettz9 commented Apr 11, 2016

@erik-southmedia : We have worked around this particular issue, so if you could test, that would be great.

@aaronpowell , FWIW, according to MDN, target and currentTarget will differ with bubbling. Since the listener is only on the upgradeneeded transaction, they should not be different. IndexedDBShim probably should support this to be safe (probably moreso with errors that bubble), but anyways, this has all been worked around in the now merged currentTarget PR, so this issue could be closed (unless you want to wait for confirmation that the shim does not have another problem).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants