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

Added support for options without a value attribute. Fixes #633 #671

Merged

Conversation

twolfson
Copy link
Contributor

@twolfson twolfson commented Mar 1, 2015

As noted in #633, we are not properly treating option's without a value attribute. This PR adds back functionality that emulates the DOM and thus jQuery behavior. In this PR:

  • Added tests for value-less options (e.g. normal, with HTML entities, with HTML elements)
  • Added patches for attr and val

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 98.62% when pulling db4eedb on twolfson:dev/fallback.select.content.sqwished into ccd9369 on cheeriojs:master.

@@ -308,7 +320,11 @@ describe('$(...)', function() {
});
it('.val(): on multiple select should get an array of values', function() {
var val = $('select#multi').val();
expect(val).to.have.length(2);
expect(val).to.have.eql(['2', '3']);
Copy link
Member

Choose a reason for hiding this comment

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

.to.eql would be more appropriate :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But I can English good =(

Heh, nice catch. I will fix it this weekend.

@fb55
Copy link
Member

fb55 commented Mar 6, 2015

Besides the unnecessary have inside two tests: LGTM.

@twolfson twolfson force-pushed the dev/fallback.select.content.sqwished branch from db4eedb to d6d1254 Compare March 7, 2015 22:35
@twolfson
Copy link
Contributor Author

twolfson commented Mar 7, 2015

I have updated the PR with the requested changes.

@@ -1,10 +1,12 @@
var _ = require('lodash'),
static = require('../static'),
Copy link
Contributor

Choose a reason for hiding this comment

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

static is reserved as a future keyword. Perhaps we should use static_ instead.

Copy link
Member

Choose a reason for hiding this comment

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

Better yet, we could avoid defining the variable altogether:

-  static = require('../static'),
   // ...
-  text = static.text,
+  text = require('./static').text,

Besides side-stepping the naming problem, this makes the file a little more maintainable--it's clear that only the exported text method is used here (as opposed to "anything in the static module").

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used this style for consistency with the file as is. I suggest that if we make that change then all other utils should have a similar format:

   isTag = require('../utils').isTag,
   domEach = require('../utils').domEach,
   hasOwn = Object.prototype.hasOwnProperty,
   camelCase = require('../utils').camelCase,
   cssCase = require('../utils').cssCase,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like we are using $ for static in other files. I am going to switch to that for consistency for now:

https://github.com/cheeriojs/cheerio/blob/0.18.0/lib/api/manipulation.js#L3

@twolfson twolfson force-pushed the dev/fallback.select.content.sqwished branch from d6d1254 to 2e6d6df Compare March 8, 2015 21:28
@twolfson
Copy link
Contributor Author

twolfson commented Mar 8, 2015

I have updated the PR with the requested changes.

fb55 added a commit that referenced this pull request Feb 1, 2016
…ished

Added support for options without a `value` attribute. Fixes #633
@fb55 fb55 merged commit b5531bb into cheeriojs:master Feb 1, 2016
@fb55
Copy link
Member

fb55 commented Feb 1, 2016

@twolfson Sorry for the delay – and thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants