|
|
@@ -24,6 +24,52 @@ module.exports = {
|
|
|
|
|
|
priority: 850,
|
|
|
|
|
|
+ bind: function () {
|
|
|
+ var attr = this.arg
|
|
|
+ // handle interpolation bindings
|
|
|
+ if (this.descriptor.interp) {
|
|
|
+ // only allow binding on native attributes
|
|
|
+ if (!(
|
|
|
+ // class is allowed globally
|
|
|
+ attr === 'class' ||
|
|
|
+ // data attributes are allowed globally
|
|
|
+ /^data-/.test(attr) ||
|
|
|
+ // for available
|
|
|
+ (attr === 'for' && 'htmlFor' in this.el) ||
|
|
|
+ // camelized prop available
|
|
|
+ _.camelize(attr) in this.el
|
|
|
+ )) {
|
|
|
+ process.env.NODE_ENV !== 'production' && _.warn(
|
|
|
+ attr + '="' + this.descriptor.raw + '": ' +
|
|
|
+ 'attribute interpolation is allowed only ' +
|
|
|
+ 'in valid native attributes. "' + attr + '" ' +
|
|
|
+ 'is not a valid attribute on <' + this.el.tagName.toLowerCase() + '>.'
|
|
|
+ )
|
|
|
+ this.invalid = true
|
|
|
+ }
|
|
|
+
|
|
|
+ if (process.env.NODE_ENV !== 'production') {
|
|
|
+ var raw = attr + '="' + this.descriptor.raw + '": '
|
|
|
+ // warn src
|
|
|
+ if (attr === 'src') {
|
|
|
+ _.warn(
|
|
|
+ raw + 'interpolation in "src" attribute will cause ' +
|
|
|
+ 'a 404 request. Use v-bind:src instead.'
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ // warn style
|
|
|
+ if (attr === 'style') {
|
|
|
+ _.warn(
|
|
|
+ raw + 'interpolation in "style" attribtue will cause ' +
|
|
|
+ 'the attribtue to be discarded in Internet Explorer. ' +
|
|
|
+ 'Use v-bind:style instead.'
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
update: function (value) {
|
|
|
if (this.invalid) return
|
|
|
var attr = this.arg
|
|
|
@@ -49,50 +95,3 @@ module.exports = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-if (process.env.NODE_ENV !== 'production') {
|
|
|
- module.exports.bind = function () {
|
|
|
- var attr = this.arg
|
|
|
- // handle interpolation bindings
|
|
|
- if (this.descriptor.interp) {
|
|
|
- var raw = attr + '="' + this.descriptor.raw + '": '
|
|
|
- // only allow binding on native attributes
|
|
|
- if (
|
|
|
- // data attributes are allowed
|
|
|
- !(/^data-/.test(attr)) &&
|
|
|
- // class is allowed
|
|
|
- !(attr === 'class') &&
|
|
|
- (
|
|
|
- // label for
|
|
|
- (attr === 'for' && !('htmlFor' in this.el)) ||
|
|
|
- // other native attributes
|
|
|
- !(_.camelize(attr) in this.el)
|
|
|
- )
|
|
|
- ) {
|
|
|
- _.warn(
|
|
|
- raw + 'attribute interpolation is allowed only ' +
|
|
|
- 'in valid native attributes. "' + attr + '" ' +
|
|
|
- 'is not a valid attribute on <' + this.el.tagName.toLowerCase() + '>.'
|
|
|
- )
|
|
|
- this.invalid = true
|
|
|
- }
|
|
|
-
|
|
|
- // warn src
|
|
|
- if (attr === 'src') {
|
|
|
- _.warn(
|
|
|
- raw + 'interpolation in "src" attribute will cause ' +
|
|
|
- 'a 404 request. Use v-bind:src instead.'
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- // warn style
|
|
|
- if (attr === 'style') {
|
|
|
- _.warn(
|
|
|
- raw + 'interpolation in "style" attribtue will cause ' +
|
|
|
- 'the attribtue to be discarded in Internet Explorer. ' +
|
|
|
- 'Use v-bind:style instead.'
|
|
|
- )
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|