Skip to content

Commit

Permalink
Added "transparent" color keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeche committed Feb 11, 2013
1 parent b7bb25a commit 98f3c1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions javascript/resolvers/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ emmet.define('cssResolver', function(require, _) {
prefs.define('css.keywords', 'auto, inherit',
'A comma-separated list of valid keywords that can be used in CSS abbreviations.');

prefs.define('css.keywordAliases', 'a:auto, i:inherit, s:solid, da:dashed, do:dotted',
prefs.define('css.keywordAliases', 'a:auto, i:inherit, s:solid, da:dashed, do:dotted, t:transparent',
'A comma-separated list of keyword aliases, used in CSS abbreviation. '
+ 'Each alias should be defined as <code>alias:keyword_name</code>.');

Expand Down Expand Up @@ -249,6 +249,10 @@ emmet.define('cssResolver', function(require, _) {

function normalizeHexColor(value) {
var hex = value.replace(/^#+/, '') || '0';
if (hex.toLowerCase() == 't') {
return 'transparent';
}

var repeat = require('utils').repeatString;
var color = null;
switch (hex.length) {
Expand Down Expand Up @@ -657,7 +661,7 @@ emmet.define('cssResolver', function(require, _) {

while (ch = stream.next()) {
if (ch == '#') {
stream.match(/^[0-9a-f]+/i, true);
stream.match(/^t|[0-9a-f]+/i, true);
values.push(stream.current());
} else if (ch == '-') {
if (isValidKeyword(_.last(values)) ||
Expand Down
1 change: 1 addition & 0 deletions javascript/unittest/tests/css-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ test('Abbreviation expanding', function() {
equal(css.expandToSnippet('c#3d3d3d'), 'color: #3d3d3d;', 'Expanded "c#3d3d3d"');
equal(css.expandToSnippet('c#d3d3d3'), 'color: #d3d3d3;', 'Expanded "c#d3d3d3"');
equal(css.expandToSnippet('c#'), 'color: #000;', 'Expanded "c#"');
equal(css.expandToSnippet('c#t'), 'color: transparent;', 'Expanded "c#t"');
equal(css.expandToSnippet('bdt2-s#ED'), 'border-top: 2px solid #EDEDED;', 'Expanded "bdt2-s#ED" (color uppercase)');
equal(css.expandToSnippet('p10%'), 'padding: 10%;', 'Expanded "p10%"');
});
Expand Down

0 comments on commit 98f3c1c

Please sign in to comment.