TylerBreau opened a new issue, #182:
URL: https://github.com/apache/cordova-common/issues/182

   # Bug Report
   
   ## Problem
   PluginInfo getPreferences is designed in a way that prevents safely adding 
new attributes.
   
   While I am not aware of a need to add new attributes to the preference tag, 
if a need comes up in the future it does not appear to be supported at all. 
   
   ### What is expected to happen?
   Adding new attributes should probably be possible.
   
   
   ### What does actually happen?
   Preferences are aggregated into a single object and the value in the name 
attribute is used to create new attributes on this object.
   Common attributes are overwritten. For example if you have 2 preferences 
with the names pref1 and pref2.
   The object will contain 1 name attribute with either the value pref1 or 
pref2.
   
   If you wanted to add a new attribute, difference preferences would override 
each other's new attribute.
   
   ## Information
   <!-- Include all relevant information that might help understand and 
reproduce the problem -->
    I noticed this while preparing unit tests for the XML Passthrough update, 
https://github.com/apache/cordova-common/pull/181.
   
           Seems like it is not possible to support additional attributes on 
preferences.
   ```
   describe('Preference', () => {
       it('Test 007: Preference supports xml passthrough', function () {
           const preferences = pluginPassthrough.getPreferences('android');
           console.log(preferences);
           expect(preferences.passthroughpref.anattrib).toBe('value');
       });
   });
   
   
   <preference name="passthroughpref" anattrib="value" />
   <!-- <preference name="passthroughpref2" anattrib="value2" /> -->
   
   { name: 'passthroughpref', anattrib: 'value', PASSTHROUGHPREF: null }
   
   
   
   <preference name="passthroughpref" anattrib="value" />
   <preference name="passthroughpref2" anattrib="value2" />
   
   {
     name: 'passthroughpref2',
     anattrib: 'value2',
     PASSTHROUGHPREF: null,
     PASSTHROUGHPREF2: null
   }
   ```
   
   _Originally posted by @TylerBreau in 
https://github.com/apache/cordova-common/issues/181#issuecomment-1284078001_
         
   
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   XML file with 2 or more preferences.
   You will see attributes like name will overwrite eachother.
   
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you 
experiencing the issue? -->
   N/A
   
   
   ### Version information
   <!--
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   cordova-common master, commit fc966d136c719285eb9a9c9d4470ed6f7da8163d
   
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to