Skip to content

Loading…

workaround for hasAttribute() calls found in custom-select #5506

Closed
wants to merge 2 commits into from

3 participants

@erikyuzwa

hasAttribute only supported on IE8+ so using a getAttribute workaround.

erikyuzwa added some commits
@erikyuzwa erikyuzwa Update js/widgets/forms/select.custom.js
hasAttribute only supported on IE8+ so using a getAttribute workaround.
8456f3f
@erikyuzwa erikyuzwa Update js/widgets/forms/select.custom.js
accidentally swapped true / false
d66884c
@guestnav
@gabrielschulhof

I shortened the code a little bit. I'm assuming that !e.hasAttribute( "x" ) is equivalent to e.getAttribute( "x" ) === null. I hope that assumption is valid.

@erikyuzwa

ooo that looks way prettier. Thanks for the lesson @gabrielschulhof

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 21, 2013
  1. @erikyuzwa

    Update js/widgets/forms/select.custom.js

    erikyuzwa committed
    hasAttribute only supported on IE8+ so using a getAttribute workaround.
  2. @erikyuzwa

    Update js/widgets/forms/select.custom.js

    erikyuzwa committed
    accidentally swapped true / false
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 3 deletions.
  1. +11 −3 js/widgets/forms/select.custom.js
View
14 js/widgets/forms/select.custom.js
@@ -105,7 +105,13 @@ define( [
self.refresh();
if ( self._origTabIndex === undefined ) {
- self._origTabIndex = self.select[ 0 ].hasAttribute( "tabindex" ) ? self.select.attr( "tabindex" ) : undefined;
+
+ var t = self.select[0].getAttribute("tabindex") == null ? false : true;
+ self._origTabIndex = undefined;
+ if(t){
+ self._origTabIndex = self.select.attr( "tabindex" );
+ }
+
// Map undefined to false, because self._origTabIndex === undefined
// indicates that we have not yet checked whether the select has
// originally had a tabindex attribute, whereas false indicates that
@@ -466,9 +472,11 @@ define( [
// If we have identified a placeholder, record the fact that it was
// us who have added the placeholder to the option and mark it
// retroactively in the select as well
- if ( !option.hasAttribute( dataPlaceholderAttr ) ) {
- this._removePlaceholderAttr = true;
+ var t = option.getAttribute(dataPlaceholderAttr) == null ? false : true;
+ if ( !t) {
+ this._removePlaceholderAttr = true;
}
+
option.setAttribute( dataPlaceholderAttr, true );
if ( o.hidePlaceholderMenuItems ) {
classes.push( "ui-selectmenu-placeholder" );
Something went wrong with that request. Please try again.