diff --git a/src/compiler.js b/src/compiler.js index 661a2b1a6f3..08ff528d9f1 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -11,7 +11,8 @@ var Emitter = require('./emitter'), vmAttr, repeatAttr, partialAttr, - transitionAttr + transitionAttr, + preAttr /* * The DOM compiler @@ -182,7 +183,8 @@ CompilerProto.compile = function (node, root) { var compiler = this if (node.nodeType === 1) { // a normal node - var repeatExp = node.getAttribute(repeatAttr), + if (node.hasAttribute(preAttr)) return + var repeatExp = node.getAttribute(repeatAttr), vmId = node.getAttribute(vmAttr), partialId = node.getAttribute(partialAttr) // we need to check for any possbile special directives @@ -589,10 +591,11 @@ CompilerProto.destroy = function () { */ function refreshPrefix () { var prefix = config.prefix - repeatAttr = prefix + '-repeat' + repeatAttr = prefix + '-repeat' vmAttr = prefix + '-viewmodel' partialAttr = prefix + '-partial' transitionAttr = prefix + '-transition' + preAttr = prefix + '-pre' } /* diff --git a/test/unit/specs/directives.js b/test/unit/specs/directives.js index 80c8028786a..80edbf0ed2b 100644 --- a/test/unit/specs/directives.js +++ b/test/unit/specs/directives.js @@ -537,6 +537,25 @@ describe('UNIT: Directives', function () { }) + describe('pre', function () { + + it('should skip compilation', function () { + var testId = 'pre-test' + mock(testId, '{{lol}}') + var t = new Seed({ + el: '#' + testId, + scope: { + lol: 'heyhey', + hi: 'hohoho' + } + }) + assert.strictEqual(t.$el.querySelector('strong').textContent, '{{lol}}') + assert.strictEqual(t.$el.querySelector('a').textContent, '') + assert.ok(t.$el.querySelector('a').hasAttribute('sd-text')) + }) + + }) + }) function mockDirective (dirName, tag, type) {