From 0eecb94b77329eb72572ee2ab0de54468a165890 Mon Sep 17 00:00:00 2001 From: Mihai Balan Date: Sat, 31 Mar 2012 01:14:58 +0300 Subject: [PATCH] Initial version with complete behavior testing --- feature-detects/css-regions.js | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 feature-detects/css-regions.js diff --git a/feature-detects/css-regions.js b/feature-detects/css-regions.js new file mode 100644 index 0000000000..9b0d68740b --- /dev/null +++ b/feature-detects/css-regions.js @@ -0,0 +1,38 @@ +// CSS Regions +// http://www.w3.org/TR/css3-regions/ +// By: Mihai Balan + +// Simple, CSS parser based +Modernizr.addTest('regions', + Modernizr.testAllProps('flowInto') +); + +// More complete, behavior based version +Modernizr.addTest('regions', function() { + if (Modernizr.testAllProps('flowInto')) { + var style = 'position: fixed; width: 20px; height: 20px; visibility: hidden;'; + var contentStyle = 'top: -50px; left: -50px;'; + var regionStyle = 'top: -100px; left: 0px;'; + + var contentDiv = document.createElement('div'); + contentDiv.style.cssText = style + contentStyle; + contentDiv.style[Modernizr.prefixed('flowInto')] = 'f1'; + + var regionDiv = document.createElement('div'); + regionDiv.style.cssText = style + regionStyle; + regionDiv.style[Modernizr.prefixed('flowFrom')] = 'f1'; + + var contentRect = contentDiv.getBoundingClientRect(); + + delete contentDiv; + delete regionDiv; + + if (contentRect.left < 0) { + return false; + } else { + return true; + } + } else { + return false; + } +}); \ No newline at end of file