[MAGNOLIA-1182] function $() name collision in javascript with prototype.js using IE Created: 06/Nov/06  Updated: 23/Jan/13  Resolved: 09/Mar/10

Status: Closed
Project: Magnolia
Component/s: admininterface
Affects Version/s: 3.0 RC3
Fix Version/s: 4.3

Type: Bug Priority: Major
Reporter: Andy McDowall Assignee: Philipp Bärfuss
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Internet Explorer 6/7 (and probably lower versions), pages that use prototype.js


Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

The problem reported in issue 794 (http://jira.magnolia.info/browse/MAGNOLIA-794) still occurs in internet explorer;
the if(typeof != 'function') does not appear to prevent the re-definition of the $() function in IE.

A temporary (and hacky) fix (for those affected by this) is to re-declare the $() function as specified in prototype.js after any <cms:mainBar/> tags.



 Comments   
Comment by Andy McDowall [ 06/Nov/06 ]

Sorry I didn't mean to assign this issue as major, it should be marked as minor.

Comment by Magnolia International [ 06/Nov/06 ]

There, minor it goes

Comment by Philipp Bracher [ 17/Nov/06 ]

It is not the only problem we have with prototype.js. This library introduces its own inheritance mechanism and adds fields to the main class Object! this breaks code where you use foreach(name in obj). This was the reason why it was not used in the admincentral. In pages this should not be a problem for now.

Comment by Nickolaus Wing [ 08/Mar/10 ]

IE seems to have a separate parsing step for picking up function declarations, so wrapping a conditional around it doesn't do anything. However, you can just change:

function $(element)

{ ... }

to

$ = function (element) { ... }

which is identical in functionality, while also forcing IE to respect the evaluation of the condition.

(This change occurs at the top of m-m-admininterface/.../admin-js/generic.js)

Edited to add: this remains a problem in IE8 running Magnolia 4.2.3. We just bumped into it this past week.

Comment by Magnolia International [ 09/Mar/10 ]

done on trunk, thanks !

Generated at Mon Feb 12 03:24:27 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.