diff --git a/scripts/code.js b/scripts/code.js index 69ac0b97d2..a4847e7174 100644 --- a/scripts/code.js +++ b/scripts/code.js @@ -210,4 +210,27 @@ function listPlugins(ul) { $$('.plugin-list').forEach(listPlugins); +// small polyfill for Element#matches +if (!Element.prototype.matches) { + Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; +} + +Prism && Prism.hooks.add('complete', function (env) { + var element = env.element; + + requestAnimationFrame(function () { + if (!element.matches('div.code-toolbar > pre > code')) { + return; + } + + var pre = element.parentElement; + var wrapper = pre.parentElement; + + // transfer margin of pre to wrapper + wrapper.style.margin = window.getComputedStyle(pre).margin; + pre.style.margin = "0"; + + }); +}); + })(); diff --git a/style.css b/style.css index 221b6cd728..4f31839fac 100644 --- a/style.css +++ b/style.css @@ -414,3 +414,12 @@ label a.owner:not(:hover) { margin-bottom: 1em; margin-right: 1em; } + +/* + * Fix for Toolbar's overflow issue + */ + +div.code-toolbar { + display: block; + overflow: auto; +}