Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1031)

Unified Diff: polymer_1.0.4/bower_components/prism/plugins/ie8/prism-ie8.js

Issue 1205703007: Add polymer 1.0 to npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Renamed folder to 1.0.4 Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: polymer_1.0.4/bower_components/prism/plugins/ie8/prism-ie8.js
diff --git a/polymer_1.0.4/bower_components/prism/plugins/ie8/prism-ie8.js b/polymer_1.0.4/bower_components/prism/plugins/ie8/prism-ie8.js
new file mode 100644
index 0000000000000000000000000000000000000000..0cd83eca7eac88d700d4729aaa870dc2fba9c628
--- /dev/null
+++ b/polymer_1.0.4/bower_components/prism/plugins/ie8/prism-ie8.js
@@ -0,0 +1,42 @@
+(function(){
+
+if (!window.Prism) {
+ return;
+}
+
+var dummy = document.createElement('header');
+
+if (!String.prototype.trim) {
+ String.prototype.trim = function () {
+ return this.replace(/^\s+/g, '').replace(/\s+$/g, '');
+ };
+}
+
+// textContent polyfill
+if (!('textContent' in dummy) && ('innerText' in dummy) && Object.defineProperty) {
+ Object.defineProperty(Element.prototype, 'textContent', {
+ get: function() {
+ return this.innerText;
+ },
+ set: function(text) {
+ this.innerText = text;
+ }
+ });
+}
+
+// IE8 doesn't have DOMContentLoaded
+if (!document.addEventListener && 'textContent' in dummy) {
+ setTimeout(Prism.highlightAll, 10);
+}
+
+// Test if innerHTML line break bug is present
+dummy.innerHTML = '\r\n';
+
+if (dummy.textContent.indexOf('\n') === -1) {
+ // IE8 innerHTML bug: Discards line breaks
+ Prism.hooks.add('after-highlight', function(env) {
+ env.element.innerHTML = env.highlightedCode.replace(/\r?\n/g, '<br>');
+ });
+}
+
+})();

Powered by Google App Engine
This is Rietveld 408576698