This repository has been archived by the owner on Jul 24, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autocomplete CSS properties. http://webkit.org/b/17374
- Loading branch information
Showing
5 changed files
with
91 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
WebInspector.CSS = { | ||
properties: (function getCSSProperties(){ | ||
var properties = Array.convert(document.defaultView.getComputedStyle(document.documentElement, '')); | ||
// Add shorthands | ||
for (var i=0; i<properties.length; i++) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
var s = properties[i].split('-'); | ||
var j = s.length; | ||
while (--j) { | ||
var prop = s.slice(0, j).join('-'); | ||
if (typeof document.documentElement.style[prop] !== 'undefined' && properties.indexOf(prop) < 0) { | ||
properties.push(prop); | ||
} | ||
} | ||
} | ||
return properties; | ||
})() | ||
} | ||
|
||
WebInspector.CSS.properties.startsWith = function startsWith(str) | ||
{ | ||
return this.filter(function(prop){ | ||
return prop.indexOf(str) === 0 | ||
}); | ||
}; | ||
|
||
WebInspector.CSS.properties.firstStartsWith = function firstStartsWith(str) | ||
{ | ||
if (!str) return ''; | ||
for (var i=0; i<this.length; i++) { | ||
if (this[i].indexOf(str) === 0) { | ||
return this[i]; | ||
} | ||
} | ||
return ''; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit fdb0292
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some inline comments. Looking good so far.
You use
properties.length
in the loop condition AND you append toproperties
withproperties.push
down below. It looks like you could be processing the same values multiple times? Sound to me like you should cache the length of properties before you loop. Clever solution too though =).