Changeset 47003
- Timestamp:
- 12/21/2019 06:32:45 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/wp/shortcode.js
r43347 r47003 228 228 229 229 // Identify a correctly formatted `attrs` object. 230 } else if ( _. isEqual( _.keys( attrs ), [ 'named', 'numeric' ] )) {231 this.attrs = attrs;230 } else if ( _.difference( _.keys( attrs ), [ 'named', 'numeric' ] ).length === 0 ) { 231 this.attrs = _.defaults( attrs, this.attrs ); 232 232 233 233 // Handle a flat object of attributes. -
trunk/tests/qunit/wp-includes/js/shortcode.js
r46586 r47003 213 213 deepEqual( wp.shortcode.attrs('a="foo" b=\'bar\' c=baz foo "bar" \'baz\''), expected, 'attr parsed numeric attributes'); 214 214 }); 215 216 test( 'string() should accept attrs in any order', function() { 217 var expected = '[short abc123 foo="bar"]'; 218 var result; 219 220 result = wp.shortcode.string({ 221 tag : 'short', 222 type : 'single', 223 attrs : { 224 named : { foo : 'bar' }, 225 numeric : [ 'abc123' ] 226 } 227 }); 228 deepEqual( result, expected, 'attributes are accepted in any order' ); 229 230 result = wp.shortcode.string({ 231 tag : 'short', 232 type : 'single', 233 attrs : { 234 numeric : [ 'abc123' ], 235 named : { foo : 'bar' } 236 } 237 }); 238 deepEqual( result, expected, 'attributes are accepted in any order' ); 239 }); 215 240 });
Note: See TracChangeset
for help on using the changeset viewer.