Migrate error from within jQuery when using $.serialize with $.ajaxSettings.traditional

Abierto
#324 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
30/100
Tipo de issue
Documentación
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
javascript
Área
frontend, tooling

Línea de trabajo

Comienza con la advertencia de migración en warnings.md y la implementación de serialize en src/serialize.js; después, compara cómo $.param gestiona el indicador traditional. Determina si la resolución aceptada consiste en modificar la documentación o en cambiar el comportamiento de jQuery; se considera terminado cuando el camino elegido aborda claramente a los usuarios de serialize y cuenta con el respaldo de las comprobaciones pertinentes del proyecto.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

My site uses $.ajaxSettings.traditional = true, and we're working on upgrading to jQuery 3 now. The migrate script is showing a warning when I use $('form').serialize() because the implementation within jQuery uses param without checking the value of the traditional flag.

jQuery.fn.extend( {
	serialize: function() {
		return jQuery.param( this.serializeArray() );
	},
	...
})

(from serialize.js line 99-ish)

I was able to fix the warning by replacing $('form').serialize() with $.param( $('form').serializeArray() , $.ajaxSettings.traditional ), but I'm wondering for future users if it wouldn't be helpful to either:

  • Update the migrate documentation to suggest this fix (other programmers might have a hard time understanding what the problem is, since the migrate documentation doesn't reference serialize anywhere; I was confused for a bit before I realized that the offending code was within jQuery), or
  • modify the jQuery source to explicitly use the traditional flag in the serialize implementation:
     jQuery.fn.extend( {
     	serialize: function() {
     		return jQuery.param( this.serializeArray(), jQuery.ajaxSettings.traditional );
     	},
     	...
     })
    

Happy to PR if either of those is desirable.

Lenguaje dominante
JavaScript
Estrellas
2.1k
Forks
477
Merge medio
20 h 48 min
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de jquery/jquery-migrate

Todos los issues de jquery/jquery-migrate

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.