I'm trying to use the webshims polyfill in an angular app, which is also using requirejs for dependency management. I'm trying to shim the absence of the form
attribute in form fields like input
and button
, which tells the browser which form a particular button or input belongs to. IE9 lacks this feature.
I figured that the best way to use this polyfill would be to create a form directive, and invoke the $.webshims.polyfill('forms')
inside the link function.
define(['angular', 'webshims'], function(angular) {
return angular.module('myApp').directive('form', ['$window', function($window) {
return {
restrict: 'E',
scope: false,
link: function($scope, iElement, iAttrs) {
if (!(window.Modernizr.input.placeholder || window.Modernizr.input.autofocus)) {
$.webshims.setOptions({
waitReady: false
});
$.webshims.polyfill('forms');
}
}
};
}
]);
Here is how I'm loading the webshims polyfill right now:
My Requirejs configapp: {
options: {
baseUrl: 'src/apps',
stubModules: ['cs'],
paths: {
jquery: '../public/components/jquery/jquery',
....
angular: '../public/components/angular/angular',
....
webshims: '../public/components/webshim/src/polyfiller',
},
shim: {
angular: {
deps: ['jquery'],
exports: 'angular'
},
...
priority: ['angular']
}
}
}
The thing is that even though the shim loads, and even calls the correct functions, the shims don't seem to be working, as IE9 still has problems with HTML5 Form attributes (placeholder, the form attribute, etc)
What am I missing here?