我正在尝试在一个角度应用程序中使用webshims polyfill,该应用程序也使用 requirejs 进行依赖管理。我正在尝试填充form
表单字段中缺少的属性,例如input
and button
,它告诉浏览器特定按钮或输入属于哪个表单。IE9 没有这个功能。
我认为使用这个 polyfill 的最佳方法是创建一个表单指令,并调用$.webshims.polyfill('forms')
内部的链接函数。
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');
}
}
};
}
]);
这是我现在加载 webshims polyfill 的方式:
我的 Requirejs 配置app: {
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']
}
}
}
问题是即使 shim 加载,甚至调用了正确的函数,shims 似乎也没有工作,因为 IE9 仍然存在 HTML5 表单属性(占位符、表单属性等)的问题
我在这里想念什么?