-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(size): add flag to opt-out of IE support (#18)
Saves around 4K in a minified build.
- Loading branch information
1 parent
735cab5
commit 308e677
Showing
10 changed files
with
60 additions
and
78 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
if (typeof FEATURE_NO_IE === 'undefined') { | ||
// References to IE 9 in this file mean the *real* IE 9 browser, not IE 11 in 9 emulation mode. | ||
// Note that in IE 9, until the F12 are actually opened window.console is undefined! | ||
let con = window.console = window.console || {}; | ||
let nop = function() {}; | ||
// console.memory is actually Chrome-only at this point, | ||
// but Aurelia does not use it so we're cutting down on "polyfills" here. | ||
// Moreover, that object is utterly useless in other browsers, as all stats would actually be 'undefined' | ||
if (!con.memory) con.memory = {}; | ||
('assert,clear,count,debug,dir,dirxml,error,exception,group,' + | ||
'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' + | ||
'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn') | ||
.split(',') | ||
.forEach(m => { if (!con[m]) con[m] = nop; }); | ||
|
||
// This is really f***ed up IE 9 stuff. | ||
// You can be in a situation where console.log is an object, not a function. | ||
// And the magic voodoo below that should _not_ work (the Function.prototype.call.bind(object,...) part) | ||
// actually kicks IE 9 into converting that object into a real function that actually logs stuff. | ||
// See http://patik.com/blog/complete-cross-browser-console-log/ | ||
if (typeof con.log === 'object') { | ||
'log,info,warn,error,assert,dir,clear,profile,profileEnd' | ||
.split(',') | ||
.forEach(function(method) { | ||
console[method] = this.bind(console[method], console); | ||
}, Function.prototype.call); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
export function _ensureElementMatches(): void { | ||
if (Element && !Element.prototype.matches) { | ||
let proto = Element.prototype; | ||
proto.matches = proto.matchesSelector || | ||
proto.mozMatchesSelector || proto.msMatchesSelector || | ||
proto.oMatchesSelector || proto.webkitMatchesSelector; | ||
} | ||
if (Element && !Element.prototype.matches) { | ||
let proto = Element.prototype; | ||
proto.matches = proto.matchesSelector || | ||
proto.mozMatchesSelector || proto.msMatchesSelector || | ||
proto.oMatchesSelector || proto.webkitMatchesSelector; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,7 @@ | ||
export const _FEATURE = {}; | ||
|
||
_FEATURE.shadowDOM = (function() { | ||
return !!HTMLElement.prototype.attachShadow; | ||
})(); | ||
|
||
_FEATURE.scopedCSS = (function() { | ||
return 'scoped' in document.createElement('style'); | ||
})(); | ||
|
||
_FEATURE.htmlTemplateElement = (function() { | ||
return 'content' in document.createElement('template'); | ||
})(); | ||
|
||
_FEATURE.mutationObserver = (function() { | ||
return !!(window.MutationObserver || window.WebKitMutationObserver); | ||
})(); | ||
export const _FEATURE = { | ||
shadowDOM: !!HTMLElement.prototype.attachShadow, | ||
scopedCSS: 'scoped' in document.createElement('style'), | ||
htmlTemplateElement: 'content' in document.createElement('template'), | ||
mutationObserver: !!(window.MutationObserver || window.WebKitMutationObserver), | ||
ensureHTMLTemplateElement: t => t, | ||
}; |
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
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
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
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