Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding vendor prefixes to css abbreviations #13

Merged
merged 4 commits into from
Jan 26, 2018

Conversation

gushuro
Copy link
Contributor

@gushuro gushuro commented Jan 26, 2018

Modified so that when preceding a CSS abbreviation with a dash, it gets expanded with all the vendor-prefixes.

For example, -bdrd10 gets expanded to

border-right: 10px;
-webkit-border-right 10px: 
-moz-border-right: 10px;
-ms-border-right: 10px;
-o-border-right: 10px;

// Fix for https://github.com/Microsoft/vscode/issues/28933#issuecomment-309236902
// When user types in propertyname, emmet uses it to match with snippet names, resulting in width -> widows or font-family -> font: family
// Filter out those cases here.
const abbrRegex = new RegExp('.*' + abbreviation.split('').map(x => x === '$' ? '\\$' : x).join('.*') + '.*', 'i');
let abbreviationWithoutDashPrefix = abbreviation[0] == '-' ? abbreviation.slice(1) : abbreviation;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only applicable for css abbreviations. So I'd suggest to have a another function vendorPrefixCssAbbreviation that takes in abbreviation and syntax and returns a boolean. You can use isStylesheet to check the syntax as well as look for the preceeding -.

Re-use this function inside expandAbbreviationWithDash

  • rename this function as expandCssAbreviationWithVendorPrefixes
  • have a check on the syntax. Use the isStylesheet function.

Also rename expandAbbreviationWithDash to expandCssAbbreviationWithVendorPrefix

@@ -525,10 +525,10 @@ export function getExpandOptions(syntax: string, emmetConfig?: object, filter?:
};
}

export function expandAbbreviationWithDash(abbreviation: string, options: any) {
export function expandCSSAbbreviationWithVendorPrefixes(abbreviation: string, options: any) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • no need to export this function
  • rename (again, sorry!) to just expandCSSAbbreviation

@ramya-rao-a ramya-rao-a merged commit 849f04e into microsoft:master Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants