1. var _Set;
  2. /* istanbul ignore if */
  3. if (typeof Set !== 'undefined' && isNative(Set)) {
  4. // use native Set when available.//当本地set有效时使用set
  5. _Set = Set;
  6. } else {
  7. // a non-standard Set polyfill that only works with primitive keys.//一个不标准的set只会和一些简单的键工作
  8. _Set = (function () {
  9. function Set () {
  10. this.set = Object.create(null);
  11. }
  12. Set.prototype.has = function has (key) {
  13. return this.set[key] === true
  14. };
  15. Set.prototype.add = function add (key) {
  16. this.set[key] = true;
  17. };
  18. Set.prototype.clear = function clear () {
  19. this.set = Object.create(null);
  20. };
  21.  
  22. return Set;
  23. }());
  24. }
  25.  
  26. var perf;//性能
  27.  
  28. {//代码块这是es6中的,代替了立即执行匿名函数
  29. perf = inBrowser && window.performance;//Web Performance API允许网页访问某些函数来测量网页和Web应用程序的性能,包括 Navigation Timing API和高分辨率时间数据。
  30. if (perf && (!perf.mark || !perf.measure)) {
  31. perf = undefined;
  32. }
  33. }
  34.  
  35. /* */
  36.  
  37. var emptyObject = Object.freeze({});//冻结一个空的对象
  38.  
  39. /**
  40. * Check if a string starts with $ or _//检查一个字符串是否以$或者下划线为开头
  41. */
  42. function isReserved (str) {
  43. var c = (str + '').charCodeAt(0);//把参数转为字符串获取第一个字符
  44. return c === 0x24 || c === 0x5F
  45. }
  46.  
  47. /**
  48. * Define a property.//定义一个属性
  49. */
  50. function def (obj, key, val, enumerable) {
  51. Object.defineProperty(obj, key, {//Object.defineProperty给对象定义属性
  52. value: val,
  53. enumerable: !!enumerable,
  54. writable: true,
  55. configurable: true
  56. });
  57. }
  58.  
  59. /**
  60. * Parse simple path.//解析简单的路径
  61. */
  62. var bailRE = /[^\w.$]/;
  63. function parsePath (path) {
  64. if (bailRE.test(path)) {
  65. return
  66. } else {
  67. var segments = path.split('.');
  68. return function (obj) {
  69. for (var i = 0; i < segments.length; i++) {
  70. if (!obj) { return }
  71. obj = obj[segments[i]];
  72. }
  73. return obj
  74. }
  75. }
  76. }
  77.  
  78. var warn = noop;
  79. var tip = noop;
  80. var formatComponentName;
  81.  
  82. {
  83. var hasConsole = typeof console !== 'undefined';
  84. var classifyRE = /(?:^|[-_])(\w)/g;
  85. var classify = function (str) { return str
  86. .replace(classifyRE, function (c) { return c.toUpperCase(); })
  87. .replace(/[-_]/g, ''); };
  88.  
  89. warn = function (msg, vm) {
  90. if (hasConsole && (!config.silent)) {
  91. console.error("[Vue warn]: " + msg + " " + (
  92. vm ? formatLocation(formatComponentName(vm)) : ''
  93. ));
  94. }
  95. };
  96.  
  97. tip = function (msg, vm) {
  98. if (hasConsole && (!config.silent)) {
  99. console.warn("[Vue tip]: " + msg + " " + (
  100. vm ? formatLocation(formatComponentName(vm)) : ''
  101. ));
  102. }
  103. };
  104.  
  105. formatComponentName = function (vm, includeFile) {//格式化组件名称
  106. if (vm.$root === vm) {
  107. return '<Root>'
  108. }
  109. var name = vm._isVue
  110. ? vm.$options.name || vm.$options._componentTag
  111. : vm.name;
  112.  
  113. var file = vm._isVue && vm.$options.__file;
  114. if (!name && file) {
  115. var match = file.match(/([^/\\]+)\.vue$/);
  116. name = match && match[1];
  117. }
  118.  
  119. return (
  120. (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
  121. (file && includeFile !== false ? (" at " + file) : '')
  122. )
  123. };
  124.  
  125. var formatLocation = function (str) {
  126. if (str === "<Anonymous>") {
  127. str += " - use the \"name\" option for better debugging messages.";
  128. }
  129. return ("\n(found in " + str + ")")
  130. };
  131. }

vue.js源码学习分享(七)的更多相关文章

  1. vue.js源码学习分享(一)

    今天看了vue.js源码  发现非常不错,想一边看一遍写博客和大家分享 /** * Convert a value to a string that is actually rendered. *转换 ...

  2. vue.js源码学习分享(九)

    /* */ var arrayKeys = Object.getOwnPropertyNames(arrayMethods);//获取arrayMethods的属性名称 /** * By defaul ...

  3. vue.js源码学习分享(六)

    /* */ /* globals MutationObserver *///全局变化观察者 // can we use __proto__?//我们能用__proto__吗? var hasProto ...

  4. vue.js源码学习分享(八)

    /* */ var uid$1 = 0; /** * A dep is an observable that can have multiple * directives subscribing() ...

  5. vue.js源码学习分享(五)

    //配置项var config = { /** * Option merge strategies (used in core/util/options)//选项合并策略 */ optionMerge ...

  6. vue.js源码学习分享(四)

    /** * Generate a static keys string from compiler modules.//从编译器生成一个静态键字符串模块. */ function genStaticK ...

  7. vue.js源码学习分享(三)

    /** * Mix properties into target object.//把多个属性插入目标的对象 */ function extend (to, _from) { for (var key ...

  8. vue.js源码学习分享(二)

    /** * Check if value is primitive//检查该值是否是个原始值 */ function isPrimitive (value) { return typeof value ...

  9. Vue.js 源码学习笔记

    最近饶有兴致的又把最新版 Vue.js 的源码学习了一下,觉得真心不错,个人觉得 Vue.js 的代码非常之优雅而且精辟,作者本身可能无 (bu) 意 (xie) 提及这些.那么,就让我来吧:) 程序 ...

随机推荐

  1. 使用js将div高度设置为100%

      在开发的工程中使用到了一些开源的bootstrap模板进行开发,在遇到一些需要替换的内容部分部分时,经常出现高度设置100%无法生效的问题,这里来用js强行设置一下.   思路:js监听窗口的缩放 ...

  2. NOIP2013 表达式求值

    题目描述 Description 给定一个只包含加法和乘法的算术表达式,请你编程计算表达式的值. 输入描述 Input Description 输入仅有一行,为需要你计算的表达式,表达式中只包含数字. ...

  3. 蓝牙nrf52832的架构和开发(转载)

    相比TI的CC254X.DIALOG的DA1458X,nordic推出的nrf51822和nrf52832在架构和开发商都有自己独特的地方.这几颗产品都是蓝牙低功耗芯片.DA1458X使用OTP硬件架 ...

  4. BZOJ 4027: [HEOI2015]兔子与樱花

    贪心 #include<cstdio> #include<algorithm> using namespace std; int cnt,n,m,F[2000005],c[20 ...

  5. dubbo doc入门文档

    dubbo document http://dubbo.apache.org/zh-cn/docs/user/references/xml/dubbo-protocol.html

  6. JAVA-基础(六) Java.serialization 序列化

    序 列 化 序列化(serialization)是把一个对象的状态写入一个字节流的过程. Serializable接口 只有一个实现Serializable接口的对象可以被序列化工具存储和恢复.Ser ...

  7. jenkins 之 Android 打包及上传至蒲公英

    准备条件 iMAC,非必须(如果是 安卓 和 苹果 可以在同一台电脑上打包则要 Mac OS 系统的电脑,如果是只是给安卓打包 windows 电脑也是可以的, window 下 需要把 ls 换成 ...

  8. Java-一个数组中的元素复制到另一个数组

    public static void arraycopy(Object src,int srcPos,Object dest,int destPos,int length).其中五个参数分别表示为: ...

  9. 用上GIT你一定会爱上他

    前言 Git是一个开源的分布式版本控制系统,用以有效.高速的处理从很小到非常大的项目版本管理. Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控 ...

  10. install cinnamon on ubuntu 14.04

    emotion: I feel not comfortable with ubuntu 14.04 default desktop unity,i still look for a alternati ...