Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnamed/numeric attribute fix (revised) #198

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

bfintal
Copy link
Contributor

@bfintal bfintal commented Feb 25, 2015

This is a continuation of the fix for unnamed/numeric attributes. This PR replaces #180

Since the code has changed a lot since wp-shortcake#180, I’m redoing the changes
with the new file structure

// Numeric attribute names
if ( ! isNaN( attr.get( 'attr' ) ) ) {
attrs.push( '"' + attr.get( 'value' ) + '"' );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to wrap in quotes?

@danielbachhuber
Copy link
Contributor

@mattheu How do you feel about this?

@bfintal
Copy link
Contributor Author

bfintal commented Feb 26, 2015

@danielbachhuber removed the quotes

attrs.push( attr.get( 'attr' ) + '="' + attr.get( 'value' ) + '"' );

// Numeric attribute names
if ( ! isNaN( attr.get( 'attr' ) ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of double negatives here... We could check $.isNumeric( attr.get( 'attr' ) ) instead?

@mattheu
Copy link
Contributor

mattheu commented Feb 27, 2015

Whilst I'd prefer to just not support numeric/positional attributes for simplicity - it is a feature of shortcodes. 😄

This works well - I think this its the best solution to the problem.

Its a bit out of sync with master - but shouldn't be too bad to update.

@mattheu
Copy link
Contributor

mattheu commented Feb 27, 2015

A couple of issues:

I suppose the key is in the word 'numeric'... but should we also account for users who specify the shortcode attribute name as an Int?

If not all numeric attributes are supplied it should probably default to false|null| - to avoid getting out of sync. (eg - shortcode has 2 numeric attrs. Edit using shortcake and remove value of attr 1. Update. Value of 2 is now passed first...

@bfintal
Copy link
Contributor Author

bfintal commented Feb 28, 2015

@mattheu I believe handling of numeric attributes is the same. [myshortcode 1="foo"] is used as $attr[1] in the shortcode function. Take note that in WP, attribute 0 doesn't work.

I did the change. Empty unnamed attributes now appear as false when left blank in order to preserve succeeding unnamed attributes.

bfintal added 3 commits March 1, 2015 12:01
Conflicts:
	js/build/shortcode-ui.js
	js/models/shortcode.js
	js/utils/shortcode-view-constructor.js
@bfintal
Copy link
Contributor Author

bfintal commented Mar 5, 2015

Synced the code to the current master

@danielbachhuber
Copy link
Contributor

@mattheu how do you feel about this?

@danielbachhuber
Copy link
Contributor

@bfintal One more sync?

Bump @mattheu

@bfintal
Copy link
Contributor Author

bfintal commented Apr 5, 2015

Hold on, things aren't working as they are supposed to

@danielbachhuber danielbachhuber modified the milestones: v0.4.0, v0.3.0 Apr 21, 2015
@danielbachhuber
Copy link
Contributor

This will need to be handled in a later release.

@danielbachhuber danielbachhuber removed this from the v0.4.0 milestone Apr 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants