Sha256: 29432dae35d14122ad3fbe7e64e534a09d5e2e630be5ea0305ff0c8d248c54aa

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

var _ = require('../util')
var Directive = require('../directive')
var compile = require('../compiler/compile')
var transclude = require('../compiler/transclude')

/**
 * Transclude, compile and link element.
 *
 * If a pre-compiled linker is available, that means the
 * passed in element will be pre-transcluded and compiled
 * as well - all we need to do is to call the linker.
 *
 * Otherwise we need to call transclude/compile/link here.
 *
 * @param {Element} el
 * @return {Element}
 */

exports._compile = function (el) {
  var options = this.$options
  if (options._linker) {
    this._initElement(el)
    options._linker(this, el)
  } else {
    var raw = el
    el = transclude(el, options)
    this._initElement(el)
    var linker = compile(el, options)
    linker(this, el)
    if (options.replace) {
      _.replace(raw, el)
    }
  }
  return el
}

/**
 * Initialize instance element. Called in the public
 * $mount() method.
 *
 * @param {Element} el
 */

exports._initElement = function (el) {
  if (el instanceof DocumentFragment) {
    this._isBlock = true
    this.$el = this._blockStart = el.firstChild
    this._blockEnd = el.lastChild
    this._blockFragment = el
  } else {
    this.$el = el
  }
  this.$el.__vue__ = this
  this._callHook('beforeCompile')
}

/**
 * Create and bind a directive to an element.
 *
 * @param {String} name - directive name
 * @param {Node} node   - target node
 * @param {Object} desc - parsed directive descriptor
 * @param {Object} def  - directive definition object
 * @param {Function} [linker] - pre-compiled linker fn
 */

exports._bindDir = function (name, node, desc, def, linker) {
  this._directives.push(
    new Directive(name, node, this, desc, def, linker)
  )
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluentd-ui-0.3.9 vendor/assets/javascripts/bower/vue/src/instance/compile.js