-
Notifications
You must be signed in to change notification settings - Fork 165
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
add fallback if document.currentScript is not available (e.g. with Webkitties) #694
add fallback if document.currentScript is not available (e.g. with Webkitties) #694
Conversation
Build succeeded. |
a, pathname, pos; | ||
|
||
if (document.currentScript && document.currentScript.src) { | ||
scriptElement = document.currentScript.src; | ||
} else { | ||
scriptElement = (function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this one or more separate documented functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Build succeeded. |
pathname = a.pathname; | ||
|
||
pos = pathname.lastIndexOf("/"); | ||
if (pos !== -1) { | ||
path = pathname.substr(0, pos); | ||
} | ||
} else { | ||
throw "Could not estimate installationPath of the Wodo.TextEditor."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwing is nice, but who catches this?
This script is run globally, so throwing here means wodo namespace is undefined.
Since that's exceptional i.e. an unexpected runtime environment or bad setup, showing an alert is permissible in my opinion. At any rate, documenting the expected global outcome here makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Throwing is nice, but who catches this?
Hm, right. If that is included by a <script>
element in the header, I have no idea who could catch that. Written without thinking more it seems (perhaps not wanting to spent time on the unexpected, meh).
So an alert is the usual pattern on an error during code run on inclusion of a JS file? Okay, changed.
Not clear to me: where would you expect the documentation to be done, and what exactly do you mean with "expected global outcome"?
Build succeeded. |
Works in chromium and firefox. Tried in KHTML 4.12.4 but that does not work, I'm not sure if this patch is supposed to fix that. |
add fallback if document.currentScript is not available (e.g. with Webkitties)
Thanks, WebODF is now working in Safari 👍 |
Fixes #693