Created
January 6, 2010 03:42
-
-
Save subtleGradient/269990 to your computer and use it in GitHub Desktop.
Workaround for .NET breaking on `clientID.startsWith`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Workaround for .NET breaking on `clientID.startsWith` | |
// Name: MicrosoftAjaxWebForms.debug.js | |
// Assembly: System.Web.Extensions | |
// Line: 722 | |
// Error: Object doesn't support this property or method | |
/* | |
function Sys$WebForms$PageRequestManager$_matchesParentIDInList | |
(clientID, parentIDList) { | |
for (var i = 0, l = parentIDList.length; i < l; i++) { | |
if (clientID.startsWith(parentIDList[i] + "_")) { | |
return true; | |
} | |
} | |
return false; | |
} | |
*/ | |
// Workaround | |
Function.prototype.startsWith = function(){ return false; }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Explaination of what's going wrong with this code | |
while (element) { | |
if (element.id) element.id.startsWith("whatever"); | |
// when element is an Element its `id` is a string | |
// when element is a Document its `id` is usually undefined | |
// when a JavaScript framework sets document.id to a function, | |
// its `id` will not have the `startsWith` method | |
// | |
// If they used `element.getAttribute('id')` instead, this wouldn't be a problem | |
// If JavaScript frameworks did not set document.id to a function then this wouldn't be a problem | |
element = element.parentNode; | |
} | |
// Complete original source | |
// from http://www.infinitezest.com/SourceViewer/AJAXSourceMethod.aspx?Method=_getPostBackSettings(element,%20elementUniqueID) | |
function Sys$WebForms$PageRequestManager$_getPostBackSettings(element, elementUniqueID) { | |
var originalElement = element; | |
var proposedSettings = null; | |
while (element) { | |
if (element.id) { | |
if (!proposedSettings && Array.contains(this._asyncPostBackControlClientIDs, element.id)) { | |
proposedSettings = this._createPostBackSettings(true, this._scriptManagerID + '|' + elementUniqueID, originalElement); | |
} | |
else { | |
if (!proposedSettings && Array.contains(this._postBackControlClientIDs, element.id)) { | |
return this._createPostBackSettings(false, null, null); | |
} | |
else { | |
var indexOfPanel = Array.indexOf(this._updatePanelClientIDs, element.id); | |
if (indexOfPanel !== -1) { | |
if (this._updatePanelHasChildrenAsTriggers[indexOfPanel]) { | |
return this._createPostBackSettings(true, this._updatePanelIDs[indexOfPanel] + '|' + elementUniqueID, originalElement); | |
} | |
else { | |
return this._createPostBackSettings(true, this._scriptManagerID + '|' + elementUniqueID, originalElement); | |
} | |
} | |
} | |
} | |
if (!proposedSettings && this._matchesParentIDInList(element.id, this._asyncPostBackControlClientIDs)) { | |
proposedSettings = this._createPostBackSettings(true, this._scriptManagerID + '|' + elementUniqueID, originalElement); | |
} | |
else { | |
if (!proposedSettings && this._matchesParentIDInList(element.id, this._postBackControlClientIDs)) { | |
return this._createPostBackSettings(false, null, null); | |
} | |
} | |
} | |
element = element.parentNode; | |
} | |
if (!proposedSettings) { | |
return this._createPostBackSettings(false, null, null); | |
} | |
else { | |
return proposedSettings; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I am using mootools in sharepoint 2013.
I am getting error in ie8 as "Object doesn't support this property or method". in my sharepoint master page I included as below
Not sure where it is conflicting. Please help me out with solution