Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 90c912e

Browse files
committed
Merge pull request #8739 from MarcelGerber/wp-docs-vendor-prefixes
Quick Docs: Ignore vendor prefixes if needed
2 parents c3e15db + 885e898 commit 90c912e

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

src/extensions/default/WebPlatformDocs/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ define(function (require, exports, module) {
110110
.done(function (cssDocs) {
111111
// Construct inline widget (if we have docs for this property)
112112
var cssPropDetails = cssDocs.PROPERTIES["css/properties/" + cssPropName];
113+
if (!cssPropDetails) {
114+
cssPropName = cssPropName.replace(/^-(webkit|moz|ms|o)-/, ""); // remove possible vendor prefixes
115+
if (cssPropName) {
116+
cssPropDetails = cssDocs.PROPERTIES["css/properties/" + cssPropName];
117+
}
118+
}
113119
if (cssPropDetails) {
114120
var inlineWidget = new InlineDocsViewer(cssPropName, cssPropDetails);
115121
inlineWidget.load(hostEditor);

src/extensions/default/WebPlatformDocs/unittest-files/test1.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
{{3}}does-not-exist: 0;
44
/* {{5}}color: #000 */
55
background: border{{4}};
6-
}
6+
{{6}}-webkit-animation: none;
7+
{{7}}-border-width: 2px;
8+
}

src/extensions/default/WebPlatformDocs/unittests.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ define(function (require, exports, module) {
139139
queryInlineAtPos(testCSSInfo, 3, false);
140140
});
141141

142+
it("should open docs for a vendor-prefixed CSS property", function () {
143+
/* css -webkit- prefixed property */
144+
queryInlineAtPos(testCSSInfo, 6, true, "animation");
145+
});
146+
147+
it("should not open docs for an invalid CSS property (looking like a vendor-prefixed one)", function () {
148+
/* css property invalidly prefixed */
149+
queryInlineAtPos(testCSSInfo, 7, false);
150+
});
151+
142152
});
143153

144154
describe("InlineDocsProvider parsing in HTML", function () {

src/language/CSSUtils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ define(function (require, exports, module) {
237237
testToken.type === "tag") {
238238
propName = testToken.string;
239239
offset = 0;
240+
} else if (testToken.type === "meta" || testToken.string === "-") {
241+
ctx.pos = testPos;
242+
ctx.token = testToken;
243+
return _getPropNameInfo(ctx);
240244
}
241245
}
242246

0 commit comments

Comments
 (0)