Skip to content

Commit 21c011e

Browse files
committed
remove attributes at link time instead of compile
1 parent de966f6 commit 21c011e

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/compile/compile.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,6 @@ function collectDirectives (el, options, asParent) {
460460
dirDef = options.directives[dirName]
461461
_.assertAsset(dirDef, 'directive', dirName)
462462
if (dirDef) {
463-
if (dirName !== 'cloak') {
464-
el.removeAttribute(attrName)
465-
}
466463
dirs.push({
467464
name: dirName,
468465
descriptors: dirParser.parse(attr.value),

src/directive.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var _ = require('./util')
2+
var config = require('./config')
23
var Watcher = require('./watcher')
34
var textParser = require('./parse/text')
45
var expParser = require('./parse/expression')
@@ -50,6 +51,9 @@ var p = Directive.prototype
5051
*/
5152

5253
p._bind = function (def) {
54+
if (this.name !== 'cloak' && this.el.removeAttribute) {
55+
this.el.removeAttribute(config.prefix + this.name)
56+
}
5357
if (typeof def === 'function') {
5458
this.update = def
5559
} else {

test/unit/specs/compile/compile_spec.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ if (_.inBrowser) {
5050
})
5151
var linker = compile(el, options)
5252
expect(typeof linker).toBe('function')
53-
// should remove attributes
54-
expect(el.attributes.length).toBe(0)
55-
expect(el.firstChild.attributes.length).toBe(0)
56-
expect(el.lastChild.attributes.length).toBe(0)
5753
linker(vm, el)
5854
expect(vm._bindDir.calls.count()).toBe(4)
5955
expect(vm._bindDir).toHaveBeenCalledWith('a', el, descriptorB, defA)

0 commit comments

Comments
 (0)