added FeatureNameInBrowser
authorDominique Hazael-Massieux <dom@w3.org>
Mon, 03 Jun 2013 17:49:23 +0200
changeset 55 c65aa59152e4
parent 54 7247f3d5ec34
child 56 93a2bc8f09b4
added FeatureNameInBrowser
submitted/W3C/featuredetection.js
--- a/submitted/W3C/featuredetection.js	Mon Jun 03 17:28:19 2013 +0200
+++ b/submitted/W3C/featuredetection.js	Mon Jun 03 17:49:23 2013 +0200
@@ -36,6 +36,33 @@
     return undefined;
 }
 
+// returns the name of the feature in the said browser
+function FeatureNameInBrowser(parent, feature, isAttribute)
+{
+    if (parent[feature] !== undefined)
+    {
+        //feature is defined without a vendor prefix, no further checks necessary
+        return feature;
+    }
+
+    // the feature is not defined without a vendor prefix, so find the vendor prefix, if any,
+    // that it is defined with
+    var prefix = GetVendorPrefix(parent, feature, isAttribute);
+    
+    // if prefix is not undefined, then the feature has been found to exist with this prefix
+    if (prefix !== undefined)
+    {
+        var prefixedFeatureName = AppendPrefix(prefix, feature, isAttribute);
+        return prefixedFeatureName;
+    }
+
+    //The feature does not exist.
+    //Callers should check for !==undefined as the feature itself could return
+    //a Bool which would fail a typical if(feature) check
+    return undefined;
+}
+
+
 // This function returns the vendor prefix found if a certain feature is defined with it.
 // It takes the same parameters at BrowserHasFeature().
 function GetVendorPrefix(parent, feature, isAttribute)