Index: Source/devtools/front_end/documentation/DocumentationURLProvider.js |
diff --git a/Source/devtools/front_end/documentation/DocumentationURLProvider.js b/Source/devtools/front_end/documentation/DocumentationURLProvider.js |
index 1527136a7af67384e28df4e1b9ce2dfdaedacf58..cbc9a362577d9adc1dc2e95875d2a0a40b9a6f5a 100644 |
--- a/Source/devtools/front_end/documentation/DocumentationURLProvider.js |
+++ b/Source/devtools/front_end/documentation/DocumentationURLProvider.js |
@@ -26,7 +26,11 @@ WebInspector.DocumentationURLProvider._sources = [ |
{ source: window.String, url: "javascript/String/", name: "String" }, |
{ source: window.Date.prototype, url: "javascript/Date/", name: "Date.prototype" }, |
{ source: window.Date, url: "javascript/Date/", name: "Date" }, |
- { source: window.JSON, url: "javascript/JSON/", name: "JSON" } |
+ { source: window.JSON, url: "javascript/JSON/", name: "JSON" }, |
+ { source: window.Number, url: "javascript/Number/", name: "Number"}, |
+ { source: window.Number.prototype, url: "javascript/Number/", name: "Number.prototype"}, |
+ { source: window.Error.prototype, url: "javascript/Error/", name: "Error.prototype"}, |
+ { source: window.RegExp.prototype, url: "javascript/RegExp/", name: "RegExp.prototype"} |
]; |
/** |
@@ -34,6 +38,8 @@ WebInspector.DocumentationURLProvider._sources = [ |
*/ |
WebInspector.DocumentationURLProvider._urlFormat = "http://docs.webplatform.org/w/api.php?action=query&titles=%s%s&prop=revisions&rvprop=timestamp|content&format=json" |
+// FIXME: method hasOwnProperty can be used with every source object. |
apavlov
2014/08/13 14:33:30
Please remove these comment lines. Since we check
|
+// Documentation is only on javascript/Object/hasOwnProperty |
WebInspector.DocumentationURLProvider.prototype = { |
/** |
* @param {string} searchTerm |
@@ -41,17 +47,25 @@ WebInspector.DocumentationURLProvider.prototype = { |
*/ |
itemDescriptors: function(searchTerm) |
{ |
- var possibleProperties = []; |
+ var descriptors = []; |
for (var i = 0; i < WebInspector.DocumentationURLProvider._sources.length; ++i) { |
var sourceRef = WebInspector.DocumentationURLProvider._sources[i]; |
- if (sourceRef.source[searchTerm] instanceof Function) { |
- var property = { |
- url: String.sprintf(WebInspector.DocumentationURLProvider._urlFormat, sourceRef.url, searchTerm), |
- name: sourceRef.name |
- }; |
- possibleProperties.push(property); |
- } |
+ if (!sourceRef.source.hasOwnProperty(searchTerm)) |
+ continue; |
+ descriptors.push(createDescriptor(searchTerm.toUpperCase() === searchTerm ? "constants" : searchTerm)); |
+ } |
+ return descriptors; |
+ |
+ /** |
+ * @param {string} searchTerm |
+ * @return {{url: string, name: string}} |
+ */ |
+ function createDescriptor(searchTerm) |
+ { |
+ return { |
+ url: String.sprintf(WebInspector.DocumentationURLProvider._urlFormat, sourceRef.url, searchTerm), |
+ name: sourceRef.name |
+ }; |
} |
- return possibleProperties; |
} |
} |