New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

nejm

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nejm

方便在nej中使用es6

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
1
Created
Source

NEJM

使用babel转化nej的代码为commonjs规范, 解决其中this指向window和依赖问题

实现原理

  • define函数中的依赖调整成相对路径导入
  • NEJ注入的_p, _o, _f, _r变量在文件前声明
  • define中直接使用的this变量指向window
  • 使用export default导出define函数的内容
  • 删除了全局变量CMPTDEBUG相关代码
  • 删除了 patch 的支持

由于第五点和第六点的变更, 所以不支持低版本的浏览器(也不打算支持)

由于NEJ中存在飘忽不定的this指向问题, 部分this通过更改源码来指向window

变更日志

若发现其他文件存在this指向问题, 可以提issuepr修复

安装

npm i nejm --save

使用

import element from 'nejm/base/element';
import utilAjaxXdr from 'nejm/util/ajax/xhr';

utilAjaxXdr._$request({
    method: 'post',
    data: {
		param: "data"
    },
    success: function (res) {
        const showElement = element._$get('box');
        showElement.innerHTML = res.message;
    }
});

FAQs

Package last updated on 29 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts