User tests: Successful: Unsuccessful:
Set the file to "use strict" which immediately revealed a couple of bugs.
There's no JS coding style standard but I reformatted to be similar to Joomla's PHPCS standard
Added docblock style comments
Moved the browser feature sniffing out of the class so that it only executes once instead of once per form.
There are more things that could be improved in this file but this should do for now.
Labels |
Added:
?
|
Oh! thanks!
Hmm. Why is our PHP standard like:
if ($something)
{
doSomething();
}
But our JS standard like:
if (something) {
doSomething();
}
Category | ⇒ | JavaScript |
Because different languages, with different history, I guess
and
if ($something)
{
doSomething();
}
in javascript looks not good (from my point of view), it like use in css:
.style
{
color: #fff;
}
Because the PHP standard is our own whereas like 80% of our javascript stuff came from the jQuery standard I think
fixed some merge conflicts that came up somehow
@okonomiyaki3000 do you expect that this file has no content now: https://github.com/okonomiyaki3000/joomla-cms/blob/fix-html5fallback/media/system/js/html5fallback.js
?
Hmm. Probably not. Let me have a look.
I hope that, at some point, we'll be converting all the names of these files from using the -uncompressed
naming scheme to using the .min
naming scheme. Also, I bet there are some obsolete files in this directory.
Easy | No | ⇒ | Yes |
Testinstructions missing
Hello @okonomiyaki3000
Thank you for your contribution.
The last comment here was on 24th October. So the question is, Is this issue/pull request still valid?
if so please provide clear test instructions to be able to test / reproduce this issue.
If no reply is received within 4 weeks we will close this issue.
Thanks for understanding!
The problems with this code are not apparent unless javascript is being run in "strict" mode so the first thing you need to do to test it is to put:
"use strict";
Just inside the closure. Then, go to any page that uses the html5fallback file. The article edit page in the administrator, for example. Look in your browser's console. You should see some errors. This patch fixes those errors.
@okonomiyaki3000 I am confused, how could I test this? I can't seem to turn off HTML5 in the browser. Should I use some old browser?
@roland-d The first thing you have to understand is that this file is pretty badly named. It's not like something that only runs on old browsers. It runs anyway but it provides some polyfills for old browsers.
To understand what's fixed, you must understand what was broken. You'd never notice because the original file was not in strict mode. Add "use strict"
at the top of the closure in the original file and then open a page where this file used and look in your console. There should be some js errors. Probably none of the javascript on the page will work. Then switch to the updated file. Everything will work again. That is what is fixed.
I have tested this item
@okonomiyaki3000 Thank you, that was clearing things up. I was able to spot the errors and they were resolved after applying the PR.
Little by little, I want to get all of joomla's js files to use strict mode and I think it should be required for any new JavaScript.
We should see if we can enforce that for new files and implement it for existing files since it promotes better coding.
"use strict"
required
I have tested this item
Tested the patch
"Use strict" is visible after applying and the website is still working.
@okonomiyaki3000 i just found out that this patch creates issues in the configuration screen of Joomla, as you can see in my screenshot
@okonomiyaki3000 I can confirm the finding by @conconnl The error thrown is:
Error: TypeError: features.fields is undefined
Source File: http://localhost:8888/joomla-cms/media/system/js/html5fallback-uncompressed.js
Line: 383
This PR has received new commits.
I have tested this item
With the last change all is working fine now on frontend and backend as far as I can see.
I have tested this item
Retested everything, it's working fine now.
Status | Pending | ⇒ | Ready to Commit |
Labels |
Added:
?
|
Milestone |
Added: |
Status | Ready to Commit | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-07-30 14:40:13 |
Closed_By | ⇒ | wilsonge |
Category | JavaScript | ⇒ |
Labels |
Removed:
?
|
See http://joomla.github.io/coding-standards/?coding-standards/chapters/javascript.md
for JS Coding Standard