Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions lib/compass/_polyfills.scss
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,49 @@ $_digits-to-numbers: ("0": 0, "1": 1, "2": 2, "3": 3, "4": 4, "5": 5, "6": 6, "7
@function _linear-gradient($angle, $arguments...) {
@return #{'linear-gradient(#{$angle}, #{$arguments})'};
}

/// Returns a comma delimited string for all the elements according to their
/// default css3 display value.
///
/// (see compass/core/sass_extensions/functions/display.rb)
@function elements-of-type($display) {
$tags: (
block: (
'address', 'article', 'aside', 'blockquote', 'center', 'dir', 'div', 'dd',
'details', 'dl', 'dt', 'fieldset', 'figcaption', 'figure', 'form',
'footer', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'header',
'hgroup', 'isindex', 'menu', 'nav', 'noframes', 'noscript', 'ol', 'p',
'pre', 'section', 'summary', 'ul',
),
inline:(
'a', 'abbr', 'acronym', 'audio', 'b', 'basefont', 'bdo', 'big', 'br',
'canvas', 'cite', 'code', 'command', 'datalist', 'dfn', 'em', 'embed',
'font', 'i', 'img', 'input', 'keygen', 'kbd', 'label', 'mark', 'meter',
'output', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'select',
'small', 'span', 'strike', 'strong', 'sub', 'sup', 'textarea', 'time',
'tt', 'u', 'var', 'video', 'wbr',
),
inline-block:('img'),
table: ('table'),
list-item:('li'),
table-row-group:('tbody'),
table-header-group:('thead'),
table-footer-group:('tfoot'),
table-row:('tr'),
table-cell:('th', 'td'),
html5-block:(
'article', 'aside', 'details', 'figcaption', 'figure', 'footer', 'header',
'hgroup', 'menu', 'nav', 'section', 'summary'
),
html5-inline:(
'audio', 'canvas', 'command', 'datalist', 'embed', 'keygen', 'mark',
'meter', 'output', 'progress', 'rp', 'rt', 'ruby', 'time', 'video', 'wbr'
)
);
$htmlTags: join(map-get($tags, html5-block), map-get($tags, html5-inline));
$tags: map-merge($tags, (html: $htmlTags));
@if map-has-key($tags, $display) {
@return map-get($tags, $display);
}
@error 'element-of-type does not handle `#{$display}` display.';
}
176 changes: 176 additions & 0 deletions test/compass/polyfills_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,182 @@ main() async {
useSassC: useSassC);
});

group('elements-of-type', () {
const {
'block': [
'address',
'article',
'aside',
'blockquote',
'center',
'dir',
'div',
'dd',
'details',
'dl',
'dt',
'fieldset',
'figcaption',
'figure',
'form',
'footer',
'frameset',
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'hr',
'header',
'hgroup',
'isindex',
'menu',
'nav',
'noframes',
'noscript',
'ol',
'p',
'pre',
'section',
'summary',
'ul',
],
'inline': [
'a',
'abbr',
'acronym',
'audio',
'b',
'basefont',
'bdo',
'big',
'br',
'canvas',
'cite',
'code',
'command',
'datalist',
'dfn',
'em',
'embed',
'font',
'i',
'img',
'input',
'keygen',
'kbd',
'label',
'mark',
'meter',
'output',
'progress',
'q',
'rp',
'rt',
'ruby',
's',
'samp',
'select',
'small',
'span',
'strike',
'strong',
'sub',
'sup',
'textarea',
'time',
'tt',
'u',
'var',
'video',
'wbr',
],
'inline-block': ['img'],
'table': ['table'],
'list-item': ['li'],
'table-row-group': ['tbody'],
'table-header-group': ['thead'],
'table-footer-group': ['tfoot'],
'table-row': ['tr'],
'table-cell': ['th', 'td'],
'html5-block': [
'article',
'aside',
'details',
'figcaption',
'figure',
'footer',
'header',
'hgroup',
'menu',
'nav',
'section',
'summary'
],
'html5-inline': [
'audio',
'canvas',
'command',
'datalist',
'embed',
'keygen',
'mark',
'meter',
'output',
'progress',
'rp',
'rt',
'ruby',
'time',
'video',
'wbr'
],
'html': [
'article',
'aside',
'details',
'figcaption',
'figure',
'footer',
'header',
'hgroup',
'menu',
'nav',
'section',
'summary',
'audio',
'canvas',
'command',
'datalist',
'embed',
'keygen',
'mark',
'meter',
'output',
'progress',
'rp',
'rt',
'ruby',
'time',
'video',
'wbr'
],
}.forEach((display, tags) {
test('replaces $display with its tags', () async {
var cssTags = tags.join(', ');
await _expectSassOutput(
"@import 'compass/css3/filter';\n"
'#{elements-of-type($display)} {\n'
' color: white;\n'
'}\n',
'$cssTags {\n'
' color: white; }\n',
useSassC: useSassC);
});
});
});

test('support filter', () async {
await _expectSassOutput(
r'''
Expand Down