-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Replace String.trimRight() with regex in order to support IE10+ #7231
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,10 @@ | |
*/ | ||
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
|
||
// Load compatibility shims--these need to load early, be careful moving this | ||
require("utils/Compatibility"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does Require make any guarantees about the order that "sibling" require() calls are loaded in? @dangoor do you have any idea? If it's not guaranteed, I wonder if it's better to put this directly in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like a similar question + answers: http://stackoverflow.com/questions/11581611/load-files-in-specific-order-with-requirejs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The accepted answer there boils down to 'explicitly require Compatibility.js in every module that calls trimRight(),' which seems clumsy and more than a little fragile. The second answer listed there -- basically, chaining async require() calls in main.js -- sounds promising though. However, if there's any sort of guarantee that the code in this PR will work as-is, that's definitely preferable. I couldn't find any docs that said either way. Anyone have a reference or spec for RequireJS's loading order? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just found a note in the official doc: http://requirejs.org/docs/1.0/docs/api.html#order There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I read that earlier, but it's actually very vague. It seems to only pertain to JS files that aren't wrapped in a
but then...
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we should go straight to the source :-) @jrburke, does RequireJS make any guarantee about the order that sibling More detail, if needed... if module "main" does this:
Is the code in the body of A's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @peterflynn the order is not guaranteed, for two reasons:
|
||
|
||
// Load dependent non-module scripts | ||
require("widgets/bootstrap-dropdown"); | ||
require("widgets/bootstrap-modal"); | ||
|
@@ -57,7 +60,7 @@ define(function (require, exports, module) { | |
require("thirdparty/CodeMirror2/addon/mode/overlay"); | ||
require("thirdparty/CodeMirror2/addon/search/searchcursor"); | ||
require("thirdparty/CodeMirror2/keymap/sublime"); | ||
|
||
// Load dependent modules | ||
var Global = require("utils/Global"), | ||
AppInit = require("utils/AppInit"), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a | ||
* copy of this software and associated documentation files (the "Software"), | ||
* to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
* and/or sell copies of the Software, and to permit persons to whom the | ||
* Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
* DEALINGS IN THE SOFTWARE. | ||
* | ||
*/ | ||
|
||
|
||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ | ||
/*global define */ | ||
|
||
/** | ||
* Compatibility shims for running Brackets in various environments, browsers. | ||
*/ | ||
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
// [IE10] String.prototype missing trimRight() and trimLeft() | ||
if (!String.prototype.trimRight) { | ||
String.prototype.trimRight = function () { return this.replace(/\s+$/, ""); }; | ||
} | ||
if (!String.prototype.trimLeft) { | ||
String.prototype.trimLeft = function () { return this.replace(/^\s+/, ""); }; | ||
} | ||
|
||
}); |
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.
Only changes to brackets.js are whitespace changes, so these changes should be removed.